Exemple #1
0
        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);
        }
Exemple #2
0
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // Unsubscribe
            }

            if (e.NewElement != null)
            {
                var formsMap = (MapWithRoute)e.NewElement;
                mapWithRoute    = formsMap;
                calculatedRoute = formsMap.CalculatedRoute;
                flownRoute      = formsMap.FlownRoute;

                formsMap.PropertyChanged += OnChange;

                ((MapView)Control).GetMapAsync(this);
            }
        }
Exemple #3
0
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                var nativeMap = Control as MKMapView;
                nativeMap.OverlayRenderer = null;
            }

            if (e.NewElement != null)
            {
                var formsMap = (MapWithRoute)e.NewElement;
                nativeMap    = Control as MKMapView;
                mapWithRoute = formsMap;

                nativeMap.OverlayRenderer = GetOverlayRenderer;
                nativeMap.OverlayRenderer = (m, o) => {
                    if (circleRenderer == null)
                    {
                        var circle = o as MKCircle;
                        if (circle != null)
                        {
                            circleRenderer           = new MKCircleRenderer(circle);
                            circleRenderer.FillColor = UIColor.Blue;
                            circleRenderer.Alpha     = 0.5f;
                        }
                    }
                    return(circleRenderer);
                };

                formsMap.PropertyChanged += OnChange;

                addOverLayForCalulatedRoute(formsMap, nativeMap);
                addOverLayForFlownRoute(formsMap, nativeMap);
            }
        }