void UpdateRoute() { map.OverlayRenderer = GetOverlayRenderer; routeOverlay = null; var coords = new CLLocationCoordinate2D[formsMap.RouteCoordinates.Count]; var index = 0; foreach (var position in formsMap.RouteCoordinates) { coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; } routeOverlay = MKPolyline.FromCoordinates(coords); if (map.Overlays != null && map.Overlays.Any()) { map.RemoveOverlays(map.Overlays); } map.AddOverlay(routeOverlay); SetNeedsDisplay(); SetNeedsLayout(); }
private void UpdatePolyLine() { //var nativeMap = Control as MKMapView; if (polyline != null) { nativeMap.RemoveOverlay(polyline); polyline.Dispose(); } nativeMap.OverlayRenderer = GetOverlayRenderer; CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[formsMap.RouteCoordinates.Count]; int index = 0; foreach (var position in formsMap.RouteCoordinates) { coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; } var routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); polyline = routeOverlay; }
private void CreateLines() { try { var mapView = Control as MKMapView; var formsMap = Element as ExtendedMap; var lineCords = new List <CLLocationCoordinate2D>(); if (formsMap.polilenes.Count <= 0) { return; } foreach (var item in formsMap.polilenes) { lineCords.Add(new CLLocationCoordinate2D(item.Latitude, item.Longitude)); } var line = MKPolyline.FromCoordinates(lineCords.ToArray()); mapView.AddOverlay(line); mapView.SetVisibleMapRect(line.BoundingMapRect, true); } catch (Exception e) { throw; } }
private async void Init() { try { var start = new Position(); start.Latitude = driver.Lat; start.Longitude = driver.Lon; this.destination = await Ride2GoService.GetPosition(this.destinationName); var routeResult = await Ride2GoService.GetRoute(start, destination, this.riderPosition); var points = routeResult.Locations; this.MapView.AddOverlay(MKPolyline.FromCoordinates(points)); var annotation = new BasicMapAnnotation(new CLLocationCoordinate2D(driver.Lat, driver.Lon), driver.Name); this.MapView.AddAnnotation(annotation); this.TimeLabel.Text = routeResult.Eta; this.timer = new Timer(); timer.Interval = 2500; timer.Start(); timer.Elapsed += this.TimerTick; } catch (Exception e) { Application.PresentOKAlert("hallo", e.Message, this, () => { }); } }
public void AddOverlays() { // sample coordinates CLLocationCoordinate2D c1 = new CLLocationCoordinate2D(41.86337816, -72.56874647); CLLocationCoordinate2D c2 = new CLLocationCoordinate2D(41.96337816, -72.96874647); CLLocationCoordinate2D c3 = new CLLocationCoordinate2D(41.45537816, -72.76874647); CLLocationCoordinate2D c4 = new CLLocationCoordinate2D(42.34994, -71.09292); // circle MKCircle circle = MKCircle.Circle(c1, 10000.0); // 10000 meter radius map.AddOverlay(circle); // polygon MKPolygon polygon = MKPolygon.FromCoordinates(new CLLocationCoordinate2D[] { c1, c2, c3 }); map.AddOverlay(polygon); // triangle MKPolyline polyline = MKPolyline.FromCoordinates(new CLLocationCoordinate2D[] { c1, c2, c3 }); map.AddOverlay(polyline); CustomOverlay co = new CustomOverlay(c4); map.AddOverlay(co); }
public void InsertCoordinate(int index, CLLocationCoordinate2D coord) { var indexOverlay = GetOverlayIndex(ZIndex); if (_polylines.Count == 0) { // no position yet var polyline = MKPolyline.FromCoordinates(new[] { coord }); _map.InsertOverlay(polyline, indexOverlay); _polylines.Add(polyline); } else { // find the polyline to extend with the new coordinate // add position to the las polyline var polyline = _polylines.Last(); _map.RemoveOverlay(polyline); _polylines.Remove(polyline); var points = new List <CLLocationCoordinate2D>(polyline.GetCoordinates(0, (int)polyline.PointCount)); points.Add(coord); polyline = MKPolyline.FromCoordinates(points.ToArray()); _polylines.Add(polyline); _map.InsertOverlay(polyline, indexOverlay); if (polyline.PointCount == PolylineSegmentLength + 1) { // Polyline is full var nextPolyline = MKPolyline.FromCoordinates(new[] { coord }); _map.InsertOverlay(nextPolyline, indexOverlay); _polylines.Add(nextPolyline); } } }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (e.OldElement != null) { var nativeMap = Control as MKMapView; if (nativeMap != null) { nativeMap.RemoveOverlays(nativeMap.Overlays); nativeMap.OverlayRenderer = null; polylineRenderer = null; } } if (e.NewElement != null) { var formsMap = (CustomMap)e.NewElement; var nativeMap = Control as MKMapView; nativeMap.OverlayRenderer = GetOverlayRenderer; CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[formsMap.Route.Count]; int index = 0; foreach (var position in formsMap.Route) { coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; } var routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); } }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { var pointAnnotation = (PolylinePointAnnotation)annotation; var annotationView = new XIPinAnnotationView(mapView, annotation, "ximpav") { Draggable = pointAnnotation.Polyline?.CanWrite == true, AnimatesDrop = true, CanShowCallout = true, }; annotationView.DragLocationChanged += (o, e) => { var value = annotationView.Frame; if (!isDragging || mapView?.Overlays == null) { return; } if (editPolyline != null) { mapView.RemoveOverlay(editPolyline); } var newPoints = pointAnnotation.Polyline.Value.ToCoordinates(); newPoints [pointAnnotation.Index] = e.DragLocation; editPolyline = MKPolyline.FromCoordinates(newPoints); mapView.AddOverlay(editPolyline); }; return(annotationView); }
private void RoudCreateOptimization() { nativeMap.RemoveOverlays(nativeMap.Overlays); if (wholeRoad != null && wholeRoad.Count > 1) { var polylineOptions = MKPolyline.FromCoordinates(wholeRoad.ToArray()); nativeMap.AddOverlay(polylineOptions); } if (formsMap.EntirePathObjTmp != null && ((List <CLLocationCoordinate2D>)formsMap.EntirePathObjTmp).Count > 1) { List <CLLocationCoordinate2D> polyline = (List <CLLocationCoordinate2D>)formsMap.EntirePathObjTmp; var polylineOptions = MKPolyline.FromCoordinates(polyline.ToArray()); nativeMap.AddOverlay(polylineOptions); } else if (formsMap.EntirePathListTmp != null && formsMap.EntirePathListTmp.Count > 1) { var polylineOptions = CreatePolyline(formsMap.EntirePathListTmp); formsMap.EntirePathObjTmp = polylineOptions; nativeMap.AddOverlay(polylineOptions); } }
void SetupItinerary() { setupHorizontalSlider(ItineraryToShow.legs.Count); List <Leg> LegsToShow = ItineraryToShow.legs; List <CLLocationCoordinate2D> points = new List <CLLocationCoordinate2D> (); int index = 1; foreach (var leg in LegsToShow) { List <CLLocationCoordinate2D> legpoints = new List <CLLocationCoordinate2D> (); foreach (var coord in leg.googlePoints) { CLLocationCoordinate2D newCoord = new CLLocationCoordinate2D(coord.Latitude, coord.Longitude); points.Add(newCoord); legpoints.Add(newCoord); } var legpolyline = MKPolyline.FromCoordinates(legpoints.ToArray()); polylineDictionary.Add(index, legpolyline); fromNameDictionary.Add(index, leg.from); toNameDictionary.Add(index, leg.to); modeDictionary.Add(index, leg.mode); index++; } var polyline = MKPolyline.FromCoordinates(points.ToArray()); polylineDictionary.Add(0, polyline); fromNameDictionary.Add(0, ItineraryToShow.legs [0].from); toNameDictionary.Add(0, ItineraryToShow.legs [ItineraryToShow.legs.Count - 1].to); modeDictionary.Add(0, "none"); updateMapFromDictionary(0); }
private void AddPolyline(MapPolyline polyline) { var coordinates = polyline .Path .Positions .Select(point => point.ToLocation()) .ToArray(); var strokeColor = (UIColor)polyline.StrokeColor; if (strokeColor == null) { throw new KeyNotFoundException("Stroke color key not found in resources."); } var overlay = MKPolyline.FromCoordinates(coordinates); var renderer = new MKPolylineRenderer(overlay) { StrokeColor = strokeColor, LineWidth = (nfloat)polyline.StrokeThickness }; if (polyline.StrokeThickness != 0 && polyline.StrokeDashed) { renderer.LineDashPattern = new NSNumber[] { polyline.StrokeThickness, 4 }; } _overlayRenderers.Add(overlay, renderer); _internalMapView.AddOverlay(overlay); }
public void UpdatePolyLinePos() { var nativeMap = Control as MKMapView; nativeMap.OverlayRenderer = GetOverlayRenderer; if (nativeMap.Overlays != null) { foreach (IMKOverlay elem in nativeMap.Overlays) { if (!(elem is MKCircle)) { nativeMap.RemoveOverlay(elem); } } } CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[formsMap.RouteCoordinates.Count]; int index = 0; foreach (var position in formsMap.RouteCoordinates)//48.0699815 ; -1.7472885 { coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; } MKPolyline routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); }
void AddMapElements(IEnumerable <MapElement> mapElements) { foreach (var element in mapElements) { element.PropertyChanged += MapElementPropertyChanged; IMKOverlay overlay = null; switch (element) { case Polyline polyline: overlay = MKPolyline.FromCoordinates(polyline.Geopath .Select(position => new CLLocationCoordinate2D(position.Latitude, position.Longitude)) .ToArray()); break; case Polygon polygon: overlay = MKPolygon.FromCoordinates(polygon.Geopath .Select(position => new CLLocationCoordinate2D(position.Latitude, position.Longitude)) .ToArray()); break; } element.MapElementId = overlay; ((MKMapView)Control).AddOverlay(overlay); } }
MKPolyline CreatePolylineOpty(List <Plugin.Geolocator.Abstractions.Position> useList) { CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[useList.Count]; MKPolyline routeOverlay = new MKPolyline(); if (wholeRoad.Count > 0) { wholeRoad.RemoveAt(wholeRoad.Count - 1); } if (useList.Count > 1) { int index = 0; foreach (var position in useList) { coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; wholeRoad.Add(new CLLocationCoordinate2D(position.Latitude, position.Longitude)); } routeOverlay = MKPolyline.FromCoordinates(coords); } return(routeOverlay); }
private void UpdateAnnotation() { IMKOverlay[] overlays = MapView.Overlays; if (overlays != null) { MapView.RemoveOverlays(MapView.Overlays); } IMKAnnotation[] mKAnnotation = MapView.Annotations; if (mKAnnotation != null) { MapView.RemoveAnnotations(mKAnnotation); } //Access database, will create table if needed DatabaseManagement.BuildAllTables(); Data[] traces = DatabaseManagement.GetAllTraces(); //Add Overlay to map foreach (var i in traces) { MapView.AddOverlay(MKPolyline.FromCoordinates(i.locs.ToArray())); } annotationData[] annotations = DatabaseManagement.GetAllAnnotations(); //Add Overlay to map foreach (var j in annotations) { MapView.AddAnnotations(new TraceAnnotation(j)); } }
public void AddOverlay(IMapOverlay item) { if (item is ICircleOverlay) { var circle = (ICircleOverlay)item; var overlay = new UnifiedCircleOverlay(MKCircle.Circle(circle.Location.ToCoordinate(), circle.Radius)) { Data = circle }; _overlays.Add(overlay); Control.AddOverlay(overlay); return; } if (item is IPolylineOverlay) { var polyline = (IPolylineOverlay)item; var coordinates = polyline .Select(p => new CLLocationCoordinate2D(p.Latitude, p.Longitude)) .ToArray(); var overlay = new UnifiedPolylineOverlay(MKPolyline.FromCoordinates(coordinates)) { Data = polyline }; _overlays.Add(overlay); Control.AddOverlay(overlay); return; } }
/// <summary> /// Draw a route between the given geopoints. /// </summary> /// <param name="geoPoints">The geopoints of the route.</param> private void DrawRoute(OrderedRoute route, bool userLocationAvailable) { if (disposed) { return; } if (navigationPolyline != null) { Control.RemoveOverlay(navigationPolyline); } if (currentSectionPolyLine != null) { Control.RemoveOverlay(currentSectionPolyLine); } if (userLocationAvailable) { navigationPolyline = MKPolyline.FromCoordinates(route.NonFirstSections.Select(gl => new CLLocationCoordinate2D(gl.Latitude, gl.Longitude)).ToArray()); Control.AddOverlay(navigationPolyline); currentSectionPolyLine = MKPolyline.FromCoordinates(route.FirstSection.Select(gl => new CLLocationCoordinate2D(gl.Latitude, gl.Longitude)).ToArray()); Control.AddOverlay(currentSectionPolyLine); } else { navigationPolyline = MKPolyline.FromCoordinates(route.Locations.Select(gl => new CLLocationCoordinate2D(gl.Latitude, gl.Longitude)).ToArray()); Control.AddOverlay(navigationPolyline); } }
protected override void OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (e.OldElement == null) { mapView = Control as MKMapView; myMap = e.NewElement as MyMap; mapView.OverlayRenderer = (m, o) => { if (lineRenderer == null) { lineRenderer = new MKPolylineRenderer(o as MKPolyline); lineRenderer.StrokeColor = UIColor.Red; lineRenderer.FillColor = UIColor.Red; } return(lineRenderer); }; var point1 = new CLLocationCoordinate2D(37, -122); var point2 = new CLLocationCoordinate2D(37, -122.001); var point3 = new CLLocationCoordinate2D(37.001, -122.002); lineOverlay = MKPolyline.FromCoordinates(new CLLocationCoordinate2D[] { point1, point2, point3 }); mapView.AddOverlay(lineOverlay); } }
protected override void DrawRouteInMap(IEnumerable <Geoposition> positions) { var nativeCoordinates = positions.Select(p => CoordinateConverter.ConvertToNative(p)); _currentUserRoute = MKPolyline.FromCoordinates(nativeCoordinates.ToArray()); _nativeMap.AddOverlay(_currentUserRoute); }
void SetupTrip() { setupHorizontalSlider(TripToShow.Steps.Count); List <Step> LegsToShow = TripToShow.Steps; List <CLLocationCoordinate2D> points = new List <CLLocationCoordinate2D> (); int index = 1; foreach (var leg in LegsToShow) { List <CLLocationCoordinate2D> legpoints = new List <CLLocationCoordinate2D> (); foreach (var coord in leg.googlePoints) { CLLocationCoordinate2D newCoord = new CLLocationCoordinate2D(coord.Latitude, coord.Longitude); points.Add(newCoord); legpoints.Add(newCoord); } var legpolyline = MKPolyline.FromCoordinates(legpoints.ToArray()); polylineDictionary.Add(index, legpolyline); From fromPlace = new From(); fromPlace.name = leg.FromName; fromPlace.lat = leg.googlePoints [0].Latitude; fromPlace.lon = leg.googlePoints [0].Longitude; To toPlace = new To(); toPlace.name = leg.ToName; toPlace.lat = leg.googlePoints [leg.googlePoints.Count - 1].Latitude; toPlace.lon = leg.googlePoints [leg.googlePoints.Count - 1].Longitude; fromNameDictionary.Add(index, fromPlace); toNameDictionary.Add(index, toPlace); modeDictionary.Add(index, ModeType.IdToString(leg.ModeId)); index++; } var polyline = MKPolyline.FromCoordinates(points.ToArray()); polylineDictionary.Add(0, polyline); From tripFrom = new From(); tripFrom.name = TripToShow.Steps[0].FromName; tripFrom.lat = TripToShow.Steps[0].googlePoints [0].Latitude; tripFrom.lon = TripToShow.Steps[0].googlePoints [0].Longitude; To tripTo = new To(); tripTo.name = TripToShow.Steps[TripToShow.Steps.Count - 1].FromName; int googlePointsCount = TripToShow.Steps [TripToShow.Steps.Count - 1].googlePoints.Count; tripTo.lat = TripToShow.Steps[TripToShow.Steps.Count - 1].googlePoints [googlePointsCount - 1].Latitude; tripTo.lon = TripToShow.Steps[TripToShow.Steps.Count - 1].googlePoints [googlePointsCount - 1].Longitude; fromNameDictionary.Add(0, tripFrom); toNameDictionary.Add(0, tripTo); modeDictionary.Add(0, "none"); updateMapFromDictionary(0); }
private async void DrawInitialRoute() { this.destinationPosition = await Ride2GoService.GetPosition(destination); var routeResult = await Ride2GoService.GetRoute(this.driverPosition, destinationPosition, null); this.firstRoute = MKPolyline.FromCoordinates(routeResult.Locations); this.MapView.AddOverlay(this.firstRoute); }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (isLoaded) { nativeMap.RemoveOverlays(nativeMap.Overlays); } if (e.NewElement == null) { return; } if (e.OldElement != null) { nativeMap = Control as MKMapView; } element = Element as ExtendedMap; mapDelegate = new MapDelegate(); nativeMap = Control as MKMapView; nativeMap.Delegate = null; nativeMap.Delegate = mapDelegate; var formsMap = (ExtendedMap)e.NewElement; CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[element.RouteCoordinates.Count]; int index = 0; int idCounter = 1; string icon = ""; icon = element.ImageSource; foreach (var circle in element.Circles) { var annot = new CustomAnnotation(new CLLocationCoordinate2D(circle.Position.Latitude, circle.Position.Longitude), element.CustomPins.FirstOrDefault().Label, "", false, icon); annot.Id = idCounter++; nativeMap.AddAnnotation(annot); //pinCollection.Add(annot.Id, item); annotations.Add(annot); var circleOverlay = MKCircle.Circle(new CLLocationCoordinate2D(circle.Position.Latitude, circle.Position.Longitude), circle.Radius); nativeMap.AddOverlay(circleOverlay); } foreach (var position in element.RouteCoordinates) { var annot = new CustomAnnotation(new CLLocationCoordinate2D(position.Latitude, position.Longitude), element.CustomPins.FirstOrDefault().Label, "", false, icon); annot.Id = idCounter++; nativeMap.AddAnnotation(annot); //pinCollection.Add(annot.Id, item); annotations.Add(annot); coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; } var routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); }
private void AddPolyline(Polyline polyline) { if (Overlays.ContainsKey(polyline)) { return; } MKPolyline naitivePolyline = MKPolyline.FromCoordinates(polyline.Points.Select(p => new CLLocationCoordinate2D(p.Latitude, p.Longitude)).ToArray()); Overlays.Add(polyline, naitivePolyline); Control.InsertOverlay(naitivePolyline, (nuint)polyline.ZIndex, MKOverlayLevel.AboveLabels); }
protected override void DrawCalculatedRouteInMap(RouteModel route) { var drawingManager = new MapDrawingManager(FormsMap, route.Color); _nativeMap.OverlayRenderer = drawingManager.GetOverlayRenderer; var nativeCoordinates = route.RoutePoints.Select(p => CoordinateConverter.ConvertToNative(p)); _currentUserRoute = MKPolyline.FromCoordinates(nativeCoordinates.ToArray()); _nativeMap.AddOverlay(_currentUserRoute); }
/// <summary> /// Adds a polyline path based on helicopter destination and current position /// </summary> /// <param name="heliPin"></param> private void addFlightPath(CustomPin heliPin) { CoreLocation.CLLocationCoordinate2D[] cLLocationCoordinate2Ds = new CoreLocation.CLLocationCoordinate2D[2]; cLLocationCoordinate2Ds[0] = new CoreLocation.CLLocationCoordinate2D(heliPin.Position.Latitude, heliPin.Position.Longitude); cLLocationCoordinate2Ds[1] = new CoreLocation.CLLocationCoordinate2D(heliPin.HelicopterDetails.destinationPosition.Latitude, heliPin.HelicopterDetails.destinationPosition.Longitude); var currentFlightPathOptions = MKPolyline.FromCoordinates(cLLocationCoordinate2Ds); nativeMap.AddOverlay(currentFlightPathOptions); highlightedFlightPath = new Tuple <CustomPin, MKPolyline>(heliPin, currentFlightPathOptions); }
private void AddLine(CLLocationCoordinate2D location1, CLLocationCoordinate2D location2, int red, int green, int blue) { MKPolyline line1 = MKPolyline.FromCoordinates(new CLLocationCoordinate2D[] { location1, location2 }); MKPolyline line2 = MKPolyline.FromCoordinates(new CLLocationCoordinate2D[] { location1, location2 }); //subclassing MKPolyline to add a color property would not work. https://forums.xamarin.com/discussion/38410/extend-mkpolyline-to-draw-on-map-with-different-colors line2.Title = red + "|" + green + "|" + blue; LocationHistoryMap.AddOverlay(line1); LocationHistoryMap.AddOverlay(line2); lines.Add(line1); lines.Add(line2); }
CustomPin GetCustomPin(MKPointAnnotation annotation) { try { CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[((CustomMap)Element).RouteCoordinates.Count]; int index = 0; foreach (var position in ((CustomMap)Element).RouteCoordinates) { coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; } routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); if (annotation == null) { foreach (var pin in ((CustomMap)Element).CustomPins) { var position = new Position(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude); if (pin.Pin.Position == position) { return(pin); } } return(null); } else { var position = new Position(annotation.Coordinate.Latitude, annotation.Coordinate.Longitude); foreach (var pin in ((CustomMap)Element).CustomPins) { if (pin.Pin.Position == position) { return(pin); } } return(null); } } catch (Exception ex) { return(null); } }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (e.OldElement != null) { var nativeMap = Control as MKMapView; if (nativeMap != null) { // for route nativeMap.RemoveOverlays(nativeMap.Overlays); nativeMap.OverlayRenderer = null; polylineRenderer = null; // for pin nativeMap.RemoveAnnotations(nativeMap.Annotations); nativeMap.GetViewForAnnotation = null; nativeMap.CalloutAccessoryControlTapped -= OnCalloutAccessoryControlTapped; nativeMap.DidSelectAnnotationView -= OnDidSelectAnnotationView; nativeMap.DidDeselectAnnotationView -= OnDidDeselectAnnotationView; } } if (e.NewElement != null) { var formsMap = (CustomMap)e.NewElement; var nativeMap = Control as MKMapView; customPins = formsMap.CustomPins; // for route nativeMap.OverlayRenderer = GetOverlayRenderer; CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[formsMap.RouteCoordinates.Count]; int index = 0; foreach (var position in formsMap.RouteCoordinates) { coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude); index++; } var routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); // for pin nativeMap.GetViewForAnnotation = GetViewForAnnotation; nativeMap.CalloutAccessoryControlTapped += OnCalloutAccessoryControlTapped; nativeMap.DidSelectAnnotationView += OnDidSelectAnnotationView; nativeMap.DidDeselectAnnotationView += OnDidDeselectAnnotationView; } }
private void DrawRoutePolyLine(MKMapView nativeMap) { nativeMap.OverlayRenderer = GetOverlayRenderer; var coords = new CLLocationCoordinate2D[FormsMap.RoutePins.Count]; int index = 0; foreach (var pins in FormsMap.RoutePins) { coords[index] = new CLLocationCoordinate2D(pins.Position.Latitude, pins.Position.Longitude); index++; } var routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); }
private void addOverLayForFlownRoute(MapWithRoute mapWithRoute, MKMapView nativeMap) { CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[mapWithRoute.FlownRoute.Count]; int index = 0; foreach (var position in mapWithRoute.FlownRoute) { coords [index] = new CLLocationCoordinate2D(position.Lat, position.Lon); index++; } var routeOverlay = MKPolyline.FromCoordinates(coords); nativeMap.AddOverlay(routeOverlay); }