Exemplo n.º 1
0
        private void DidLongPressOnMap(UILongPressGestureRecognizer sender)
        {
            if (sender.State != UIGestureRecognizerState.Began)
            {
                return;
            }

            var point = sender.LocationInView(mapView);

            destinationCoordinate = mapView.ConvertPoint(point, mapView);
            if (mapView.Annotations != null)
            {
                mapView.RemoveAnnotations(mapView.Annotations);
            }
            mapView.AddAnnotation(new MGLPointAnnotation()
            {
                Coordinate = (CoreLocation.CLLocationCoordinate2D)destinationCoordinate
            });
            routingItem.Enabled = userCoordinate != null && destinationCoordinate != null;
        }
        private void DidLongPressOnMap(UILongPressGestureRecognizer sender)
        {
            if (sender.State != UIGestureRecognizerState.Began)
            {
                return;
            }

            CGPoint point = sender.LocationInView(map);
            CLLocationCoordinate2D coordinate2D = map.ConvertPoint(point, map);

            if (map.Annotations != null)
            {
                map.RemoveAnnotations(map.Annotations);
            }
            MGLPointAnnotation pointAnnotation = new MGLPointAnnotation();

            pointAnnotation.Coordinate = coordinate2D;
            pointAnnotation.Title      = "Start Navigation";
            map.AddAnnotation(pointAnnotation);
        }