public override void UnloadTickets() { var allTicketAnnotations = _nativeMap.Annotations?.OfType <TicketAnnotation>() .ToArray(); if (allTicketAnnotations?.Any() == true) { _nativeMap.RemoveAnnotations(allTicketAnnotations); } }
public override void RemoveAllPushins() { var allAnnotations = _nativeMap.Annotations?.OfType <CustomPinAnnotation>() .ToArray(); if (allAnnotations?.Any() == true) { _nativeMap.RemoveAnnotations(allAnnotations); } }
public override void RemoveAllCustomers() { CustomerAnnotation[] annotations = _nativeMap?.Annotations?.OfType <CustomerAnnotation>() .ToArray(); if (annotations != null) { _nativeMap.RemoveAnnotations(annotations); } }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (e.OldElement != null) { MKMapView oldMap = Control as MKMapView; if (oldMap != null) { oldMap.RemoveAnnotations(oldMap.Annotations); oldMap.GetViewForAnnotation = null; userLocationSubscription?.Dispose(); userLocationSubscription = null; } } if (e.NewElement != null) { formsMap = (MapCustomPin)e.NewElement; nativeMap = Control as MKMapView; nativeMap.GetViewForAnnotation = GetViewForAnnotation; userLocationSubscription = formsMap.WhenAnyValue(fm => fm.UserCurrentLocation).WhereNotNull().Subscribe(UserLocationSubscription, ex => Console.WriteLine(ex.Message)); } }
public void DisplayAnnotations(List <IMKAnnotation> annotations, MKMapView mapView) { List <IMKAnnotation> before = new List <IMKAnnotation>(); foreach (IMKAnnotation annotation in mapView.Annotations) { before.Add(annotation); } // MKUserLocation userLocation = mapView.UserLocation; // if (userLocation != null) // before.Remove(userLocation); List <IMKAnnotation> after = new List <IMKAnnotation>(annotations); List <IMKAnnotation> toKeep = new List <IMKAnnotation>(before); toKeep = FBUtils.Intersect(toKeep, after); List <IMKAnnotation> toAdd = new List <IMKAnnotation>(after); toAdd.RemoveAll((IMKAnnotation obj) => { return(toKeep.Contains(obj)); }); List <IMKAnnotation> toRemove = new List <IMKAnnotation>(before); toRemove.RemoveAll((IMKAnnotation obj) => { return(after.Contains(obj)); }); NSOperationQueue.MainQueue.AddOperation(delegate() { mapView.AddAnnotations(toAdd.ToArray()); mapView.RemoveAnnotations(toRemove.ToArray()); } ); }
public void removePins(object sender, EventArgs args) { if (mainMapView.Annotations != null && Polygon != null) { mainMapView.RemoveAnnotations(mainMapView.Annotations); itemsArray.RemoveRange(0, itemsArray.Count); mainMapView.RemoveOverlay(Polygon); updatePolygon(); } }
protected virtual void ReloadAllAnnotations() { _mapView.RemoveAnnotations(_annotations.Values.Select(x => (NSObject)x).ToArray()); _annotations.Clear(); if (_itemsSource == null) { return; } AddAnnotations(_itemsSource); }
private void UpdatePins() { Pins = FormsMap.BindablePins; NativeMap.RemoveAnnotations(NativeMap.Annotations); int i = 0; foreach (var pin in Pins) { var ca = new CustomAnnotation(pin, (++i).ToString(), pin.Type); NativeMap.AddAnnotation(ca); } }
protected async void OnMapTapped(UIGestureRecognizer sender) { CLLocationCoordinate2D tappedLocationCoord = map.ConvertPoint(sender.LocationInView(map), map); map.RemoveAnnotations(map.Annotations); map.AddAnnotations(new MKPointAnnotation() { Title = "Выбранная геопозиция", Coordinate = tappedLocationCoord }); int button = await ShowAlert("Вы уверены?", "Выбрать геопозицию?", "Да", "Нет"); if (button == 0) { map.RemoveFromSuperview(); } }
public void DidFinishRenderingMap(MKMapView mapView, bool fullyRendered) { mapView.RemoveAnnotations(mapView.Annotations); foreach (var city in Cities) { var location = new CLLocationCoordinate2D(latitude: city.Latitude, longitude: city.Longitude); var pointAnnotation = new MKPointAnnotation { Coordinate = location, Title = city.Title }; mapView.AddAnnotation(pointAnnotation); } }
private void LongPress(UILongPressGestureRecognizer gesture) { _mKMapView.RemoveAnnotations(_mKMapView.Annotations); CGPoint touchPoint = gesture.LocationInView(_mKMapView); CLLocationCoordinate2D touchMapCoordinate = _mKMapView.ConvertPoint(touchPoint, _mKMapView); MKAnnotationClass annotation = new MKAnnotationClass(); annotation.Coordinate2D = touchMapCoordinate; _lalitude = annotation.Coordinate2D.Latitude; _longitude = annotation.Coordinate2D.Longitude; _customMap.UserLalitude = _lalitude; _customMap.UserLongitude = _longitude; _mKMapView.AddAnnotation(annotation); _mKMapView.AddAnnotations(new MKPointAnnotation() { Coordinate = new CLLocationCoordinate2D(_lalitude, _longitude) }); }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (e.OldElement != null) { nativeMap = Control as MKMapView; if (nativeMap != null) { nativeMap.RemoveAnnotations(nativeMap.Annotations); nativeMap.GetViewForAnnotation = null; nativeMap.CalloutAccessoryControlTapped -= OnCalloutAccessoryControlTapped; nativeMap.DidSelectAnnotationView -= OnDidSelectAnnotationView; nativeMap.DidDeselectAnnotationView -= OnDidDeselectAnnotationView; nativeMap.RemoveOverlays(nativeMap.Overlays); nativeMap.OverlayRenderer = null; polygonRenderer = null; } } if (e.NewElement != null) { map = (CustomMap)e.NewElement; var nativeMap = Control as MKMapView; customPins = map.CustomPins; nativeMap.GetViewForAnnotation = GetViewForAnnotation; nativeMap.CalloutAccessoryControlTapped += OnCalloutAccessoryControlTapped; nativeMap.DidSelectAnnotationView += OnDidSelectAnnotationView; nativeMap.DidDeselectAnnotationView += OnDidDeselectAnnotationView; customPins = map.CustomPins; shapeCoordinates = map.ShapeCoordinates; nativeMap.DidSelectAnnotationView += onViewClick; nativeMap.ScrollEnabled = false; nativeMap.ZoomEnabled = false; } }
private void ClearPushPins(MKMapView mapView) { mapView.RemoveAnnotations(mapView.Annotations); }
public override void RemoveClusters(CKCluster[] clusters) { _internalMap.RemoveAnnotations(clusters); }
/// <summary> /// Clears all MKPlacemarks for a map view /// </summary> public static void ClearPlacemarks(this MKMapView mapView) { mapView.RemoveAnnotations(mapView.Annotations.OfType <MKPlacemark> ().ToArray()); }
void ClearPushPins(MKMapView mapView) => mapView.RemoveAnnotations(mapView.Annotations);
public void DisplayAnnotations(List<IMKAnnotation> annotations, MKMapView mapView) { List<IMKAnnotation> before = new List<IMKAnnotation>(); foreach (IMKAnnotation annotation in mapView.Annotations) before.Add(annotation); // MKUserLocation userLocation = mapView.UserLocation; // if (userLocation != null) // before.Remove(userLocation); List<IMKAnnotation> after = new List<IMKAnnotation>(annotations); List<IMKAnnotation> toKeep = new List<IMKAnnotation>(before); toKeep = FBUtils.Intersect(toKeep, after); List<IMKAnnotation> toAdd = new List<IMKAnnotation>(after); toAdd.RemoveAll((IMKAnnotation obj) => { return toKeep.Contains(obj); }); List<IMKAnnotation> toRemove = new List<IMKAnnotation>(before); toRemove.RemoveAll((IMKAnnotation obj) => { return after.Contains(obj); }); NSOperationQueue.MainQueue.AddOperation(delegate () { mapView.AddAnnotations(toAdd.ToArray()); mapView.RemoveAnnotations(toRemove.ToArray()); } ); }
void OnGUI() { KitchenSink.OnGUIBack(); if (CoreXT.IsDevice) { GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, 100)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Show Map", GUILayout.ExpandHeight(true))) { if (mapView == null) { mapView = new MKMapView(new Rect(25, 100, Screen.width / 2 - 50, Screen.height / 2 - 150)); // create custom annotation view mapView.viewHandler = delegate(MKMapView view, MKAnnotation annotation) { // try to reuse old view var annotationView = mapView.DequeueReusableAnnotationView("annoview"); if (annotationView == null) { Debug.Log("creating new annotation view"); // annotationView = new MKPinAnnotationView(annotation, "annoview"); annotationView = new MKAnnotationView(annotation, "annoview"); annotationView.canShowCallout = true; var image = new UIImage(new NSData(new NSURL("http://u3dxt.com/wp-content/uploads/2013/06/gears_14662320_s-225x225.jpg"))); annotationView.image = image; } else { Debug.Log("reusing old annotation view"); annotationView.annotation = annotation; } return(annotationView); }; } UIApplication.deviceRootViewController.view.AddSubview(mapView); MKCoordinateRegion newRegion = new MKCoordinateRegion(); newRegion.center.latitude = 37.786996; newRegion.center.longitude = -122.440100; newRegion.span.latitudeDelta = 0.112872; newRegion.span.longitudeDelta = 0.109863; mapView.SetRegion(newRegion, true); } if (GUILayout.Button("Hide Map", GUILayout.ExpandHeight(true))) { mapView.RemoveFromSuperview(); } if (GUILayout.Button("Add marker", GUILayout.ExpandHeight(true))) { Annotation ggBridge = new Annotation(new CLLocationCoordinate2D(37.810000, -122.477450), "Golden Gate Bridge", "Opened: May 27, 1937"); mapView.AddAnnotation(ggBridge); } if (GUILayout.Button("Clear marker", GUILayout.ExpandHeight(true))) { mapView.RemoveAnnotations(mapView.annotations); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } // OnGUILog(); }