Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        /* TODO Readd LFHeatMap project first
         * Found at https://github.com/TreeWatch/LFHeatMaps
         * Code:
         * void ChangeRegion(object sender, MKMapViewChangeEventArgs e){
         *
         *  foreach (var item in mapView.Subviews)
         *  {
         *      var heatMap = item as UIHeatMapView;
         *      if (heatMap != null)
         *          heatMap.RefreshHeatMap(mapView);
         *  }
         * }
         */

        /// <summary>
        /// Gets the overlay render for a overlay.
        /// </summary>
        /// <returns>The overlay render.</returns>
        /// <param name="m">The Mapview.</param>
        /// <param name="o">The Overlay.</param>
        private MKOverlayRenderer GetOverlayRender(MKMapView m, IMKOverlay o)
        {
            var overlay = Runtime.GetNSObject(o.Handle) as MKPolygon;

            if (overlay != null)
            {
                var polygon         = overlay;
                var polygonRenderer = new MKPolygonRenderer(polygon);

                if (polygon.Title == "Field")
                {
                    polygonRenderer.FillColor   = this.myMap.OverLayColor.ToUIColor();
                    polygonRenderer.StrokeColor = this.myMap.BoundaryColor.ToUIColor();
                    polygonRenderer.LineWidth   = 1;
                }

                return(polygonRenderer);
            }

            if (o is MultiPolygon)
            {
                return(new MultiPolygonView(o));
            }

            return(null);
        }
        public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
        {
            if (context is LocationActivity)
            {
                var lineOverlay = overlay as MKPolyline;

                try
                { //null exception error on lineOverlay, when stepping back from location history
                    var lineView = new MKPolylineView(lineOverlay);

                    string title = lineOverlay.GetTitle();

                    if (!(title is null))
                    {
                        string[] colors = title.Split("|");
                        int      red    = int.Parse(colors[0]);
                        int      green  = int.Parse(colors[1]);
                        int      blue   = int.Parse(colors[2]);


                        lineView.StrokeColor = UIColor.FromRGB(red, green, blue);
                        lineView.LineWidth   = 2f;
                    }
                    else
                    {
                        lineView.StrokeColor = UIColor.FromName("PrimaryDark");
                        lineView.LineWidth   = 3f;
                    }
                    return(lineView);
                }
Esempio n. 4
0
            public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlayWrapper)
            {
                var type    = overlayWrapper.GetType();
                var overlay = overlayWrapper as IMKOverlay;

                if (overlay is MKPolyline || type == typeof(MKPolyline))
                {
                    if (polylineRenderer == null)
                    {
                        polylineRenderer = new MKPolylineRenderer(overlay as MKPolyline);
                        //polylineRenderer.FillColor = UIColor.Blue;
                        polylineRenderer.StrokeColor = UIColor.Red;
                        polylineRenderer.LineWidth   = 5;
                        isLoaded = true;
                    }
                    return(polylineRenderer);
                }
                else if (overlay is MKCircle)
                {
                    if (circleRenderer == null)
                    {
                        circleRenderer           = new MKCircleRenderer(overlay as MKCircle);
                        circleRenderer.FillColor = UIColor.Red;
                        circleRenderer.Alpha     = 0.2f;
                        isLoaded = true;
                    }
                    return(circleRenderer);
                }
                return(base.OverlayRenderer(mapView, overlayWrapper));
            }
Esempio n. 5
0
        /*
         * Gets the new overlay renderer for the lines and circles
         */
        public MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlayWrapper)
        {
            var overlay = Runtime.GetNSObject(overlayWrapper.Handle) as IMKOverlay;

            if (overlay.GetType() == typeof(MKPolyline))
            {
                if (polylineRenderer == null && !Equals(overlayWrapper, null))
                {
                    polylineRenderer = new MKPolylineRenderer(overlay as MKPolyline)
                    {
                        StrokeColor = UIColor.Blue,
                        LineWidth   = (System.nfloat) 2.0,
                        Alpha       = 0.4f,
                    };
                }

                return(polylineRenderer);
            }
            else
            {
                if (circleRenderer == null && !Equals(overlayWrapper, null))
                {
                    circleRenderer = new MKCircleRenderer(overlay as MKCircle)
                    {
                        FillColor = UIColor.Black,
                        Alpha     = 0.4f,
                    };
                }
                return(circleRenderer);
            }
        }
Esempio n. 6
0
 MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (!isCircle)
     {
         if (polylineRenderer == null)
         {
             polylineRenderer             = new MKPolylineRenderer(overlay as MKPolyline);
             polylineRenderer.FillColor   = UIColor.Blue;
             polylineRenderer.StrokeColor = UIColor.Red;
             polylineRenderer.LineWidth   = 3;
             polylineRenderer.Alpha       = 0.4f;
         }
         isLoaded = true;
         return(polylineRenderer);
     }
     if (isCircle)
     {
         if (circleRenderer == null)
         {
             circleRenderer           = new MKCircleRenderer(overlay as MKCircle);
             circleRenderer.FillColor = UIColor.Red;
             circleRenderer.Alpha     = 0.4f;
         }
         isLoaded = true;
         return(circleRenderer);
     }
     return(polylineRenderer);
 }
        MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {
            #region for dotted routing between pins

            /*	var temp = new Foundation.NSNumber[2];
             *                  temp[0] = 2;
             *                  temp[1] = 10;
             *
             *                  polylineRenderer = new MKPolylineRenderer(overlay as MKPolyline);
             *                  polylineRenderer.FillColor = UIColor.Blue;
             *                  polylineRenderer.StrokeColor = UIColor.Red;
             *                  polylineRenderer.LineWidth = 3;
             *                  polylineRenderer.Alpha = 0.4f;
             *
             *                  polylineRenderer.LineDashPhase = 2;
             *                  polylineRenderer.LineDashPattern = temp;
             *                  polylineRenderer.LineJoin = CGLineJoin.Round;
             *
             *                  return polylineRenderer;*/
            #endregion
            #region for line drawing routing between pins
            if (polylineRenderer == null)
            {
                polylineRenderer             = new MKPolylineRenderer(overlay as MKPolyline);
                polylineRenderer.FillColor   = UIColor.Blue;
                polylineRenderer.StrokeColor = UIColor.FromRGB(40, 115, 221);
                polylineRenderer.LineWidth   = 3;
                polylineRenderer.Alpha       = 0.4f;
            }
            return(polylineRenderer);

            #endregion
        }
 public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (overlay is MKCircle)
     {
         if (circleRenderer == null)
         {
             circleRenderer           = new MKCircleRenderer(overlay as MKCircle);
             circleRenderer.FillColor = UIColor.Purple;
             circleRenderer.Alpha     = 0.5f;
         }
         return(circleRenderer);
     }
     else if (overlay is MKPolygon)
     {
         if (polyRenderer == null)
         {
             polyRenderer           = new MKPolygonRenderer(overlay as MKPolygon);
             polyRenderer.FillColor = UIColor.Green;
             polyRenderer.Alpha     = 0.5f;
         }
         return(polyRenderer);
     }
     else
     {
         Debug.WriteLine("OverlayRenderer() - Unknown overlay type!");
         return(null);
     }
 }
Esempio n. 9
0
 public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     return(new MKCircleRenderer(overlay as MKCircle)
     {
         FillColor = UIColor.Red,
         Alpha = 0.4f
     });
 }
Esempio n. 10
0
 public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (overlay is IUnifiedOverlay unifiedOverlay)
     {
         return(unifiedOverlay.GetRenderer());
     }
     return(null);
 }
        public MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {
            MKCircleRenderer circleRenderer = new MKCircleRenderer((MKCircle)overlay);

            circleRenderer.FillColor = UIColor.Blue;
            circleRenderer.Alpha     = 0.1f;
            return(circleRenderer);
        }
Esempio n. 12
0
        public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {
            MKPolylineRenderer polylineRenderer = new MKPolylineRenderer(overlay as MKPolyline);

            polylineRenderer.StrokeColor = UIColor.Blue;
            polylineRenderer.LineWidth   = 2f;
            return(polylineRenderer);
        }
Esempio n. 13
0
 public sealed override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (overlay is IBindingMKMapOverlay bOverlay)
     {
         return(bOverlay.Renderer);
     }
     return(null);
 }
Esempio n. 14
0
 public static MKPolylineRenderer GetPolylineRenderer(IMKOverlay overlay)
 {
     return(new MKPolylineRenderer(overlay as MKPolyline)
     {
         StrokeColor = UIColor.Blue,
         LineWidth = 4.0f
     });
 }
Esempio n. 15
0
        public SKMapOverlayRenderer(MKMapView mapView, SKMapOverlay sharedOverlay, IMKOverlay overlay) : base(overlay)
        {
            _SharedOverlay = sharedOverlay;
            _NativeMap     = mapView;

            _overlayDirtySubscription = _SharedOverlay.WeakSubscribe <SKMapOverlay, MapOverlayInvalidateEventArgs>(nameof(_SharedOverlay.RequestInvalidate),
                                                                                                                   MarkOverlayDirty);
        }
Esempio n. 16
0
        MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {
            var circleRenderer = new MKCircleRenderer(overlay as MKCircle);

            circleRenderer.FillColor = UIColor.Yellow;
            circleRenderer.Alpha     = 0.2f;

            return(circleRenderer);
        }
Esempio n. 17
0
        public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
        {
            MKPolygon     polygon       = overlay as MKPolygon;
            MKPolygonView mKPolygonView = new MKPolygonView(polygon);

            mKPolygonView.FillColor   = UIColor.Red;
            mKPolygonView.StrokeColor = UIColor.Blue;
            return(mKPolygonView);
        }
Esempio n. 18
0
 MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (circleRenderer == null) {
         circleRenderer = new MKCircleRenderer (overlay as MKCircle);
         circleRenderer.FillColor = UIColor.Red;
         circleRenderer.Alpha = 0.4f;
     }
     return circleRenderer;
 }
 public MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     return(new MKOverlayPathRenderer(overlay)
     {
         FillColor = UIColor.Blue.ColorWithAlpha(0.2f),
         StrokeColor = UIColor.Black,
         LineWidth = 2
     });
 }
Esempio n. 20
0
 public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
 {
     // return a view for the polygon
     MKPolygon polygon = overlay as MKPolygon;
     MKPolygonView polygonView = new MKPolygonView (polygon);
     polygonView.FillColor = UIColor.Blue;
     polygonView.StrokeColor = UIColor.Red;
     return polygonView;
 }
            public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
            {
                var circleOverlay = overlay as MKCircle;
                var circleView    = new MKCircleView(circleOverlay);

                circleView.FillColor = UIColor.Red;
                circleView.Alpha     = 0.4f;
                return(circleView);
            }
Esempio n. 22
0
            public static MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
            {
                if (overlay is SKMapKitOverlay)
                {
                    return(new SKMapOverlayRenderer(mapView, (overlay as SKMapKitOverlay).SharedOverlay, overlay));
                }

                return(null);
            }
Esempio n. 23
0
        protected MKOverlayRenderer OverlayRenderer(MKMapView mapview, IMKOverlay overlay)
        {
            if (!(Runtime.GetNSObject(overlay.Handle) is MKCircle circle))
            {
                return(new MKTileOverlayRenderer((MKTileOverlay)overlay));
            }

            return(PointHandler.GetCircleRenderer(circle));
        }
Esempio n. 24
0
        public void Overlays_BackingFields()
        {
            if (MapViewPoker.NewRefcountEnabled())
            {
                Assert.Inconclusive("backing fields are removed when newrefcount is enabled");
            }

#if XAMCORE_2_0
            using (var o1 = new MKPolygon())                    // it must export 'boundingMapRect' or this will fail
                using (var o2 = new MKPolyline())
#else
            using (NSObject o1 = new MKPolygon())               // it must export 'boundingMapRect' or this will fail
                using (NSObject o2 = new MKPolyline())
#endif
                    using (var mv = new MapViewPoker()) {
#if XAMCORE_2_0
                        var overlays = new IMKOverlay [] { o1, o2 };
#else
                        var overlays = new NSObject [] { o1, o2 };
#endif
                        Assert.Null(mv.OverlaysBackingField, "1a");
                        Assert.Null(mv.Overlays, "1b");          // not an empty array

                        mv.AddOverlay(o1);
                        Assert.AreSame(o1, mv.OverlaysBackingField [0], "2a");
                        Assert.AreSame(o1, mv.Overlays [0], "2b");

                        mv.InsertOverlay(o2, 0);
                        Assert.That(mv.OverlaysBackingField.Length, Is.EqualTo(2), "3a");
                        Assert.That(mv.Overlays.Length, Is.EqualTo(2), "3b");

                        mv.RemoveOverlay(o1);
                        Assert.AreSame(o2, mv.OverlaysBackingField [0], "4a");
                        Assert.AreSame(o2, mv.Overlays [0], "4b");

                        mv.InsertOverlayAbove(o1, o2);
                        Assert.That(mv.OverlaysBackingField.Length, Is.EqualTo(2), "5a");
                        Assert.That(mv.Overlays.Length, Is.EqualTo(2), "5b");

                        mv.RemoveOverlay(o2);
                        Assert.AreSame(o1, mv.OverlaysBackingField [0], "6a");
                        Assert.AreSame(o1, mv.Overlays [0], "6b");

                        mv.InsertOverlayBelow(o2, o1);
                        Assert.That(mv.OverlaysBackingField.Length, Is.EqualTo(2), "7a");
                        Assert.That(mv.Overlays.Length, Is.EqualTo(2), "7b");

                        mv.RemoveOverlays(overlays);
                        Assert.That(mv.OverlaysBackingField, Is.Empty, "8a");
                        Assert.That(mv.Overlays, Is.Empty, "8b");

                        mv.AddOverlays(overlays);
                        Assert.That(mv.OverlaysBackingField.Length, Is.EqualTo(2), "9a");
                        Assert.That(mv.Overlays.Length, Is.EqualTo(2), "9b");
                    }
        }
Esempio n. 25
0
 public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     return(new MKPolylineRenderer(overlay as MKPolyline)
     {
         Alpha = (nfloat)alpha,
         LineWidth = (nfloat)4.0,
         FillColor = color,
         StrokeColor = color
     });
 }
 //Override OverLayRenderer to draw Polyline from directions
 public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
     {
         if (overlay is MKPolyline)
         {
             var route = (MKPolyline)overlay;
             var renderer = new MKPolylineRenderer(route) { StrokeColor = UIColor.Blue };
             return renderer;
         }
         return null;
     }
Esempio n. 27
0
 //Override OverLayRenderer to draw Polyline returned from directions
 public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (overlay is MKPolyline)
     {
         var route = (MKPolyline)overlay;
         var renderer = new MKPolylineRenderer(route) { StrokeColor = UIColor.Blue };
         return renderer;
     }
     return null;
 }
 public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     return new MKPolylineRenderer(overlay as MKPolyline)
     {
         Alpha = (nfloat) alpha,
         LineWidth = (nfloat) 4.0,
         FillColor = color,
         StrokeColor = color
     };
 }
Esempio n. 29
0
 MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (circleRenderer == null)
     {
         circleRenderer           = new MKCircleRenderer(overlay as MKCircle);
         circleRenderer.FillColor = UIColor.Red;
         circleRenderer.Alpha     = 0.4f;
     }
     return(circleRenderer);
 }
 public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
 {
     if ((_circle != null) && (_circleView == null))
     {
         _circleView           = new MKCircleView(_circle);
         _circleView.FillColor = UIColor.Blue;
         _circleView.Alpha     = 0.5f;
     }
     return(_circleView);
 }
        void ClearOverlays()
        {
            if (overlaysList.Count > 0)
            {
                NativeMapView.RemoveOverlays(overlaysList.ToArray());
                overlaysList.Clear();
            }

            currentRouteOverlay = null;
        }
Esempio n. 32
0
        public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
        {
            // return a view for the polygon
            MKPolygon     polygon     = overlay as MKPolygon;
            MKPolygonView polygonView = new MKPolygonView(polygon);

            polygonView.FillColor   = UIColor.Blue;
            polygonView.StrokeColor = UIColor.Red;
            return(polygonView);
        }
Esempio n. 33
0
 MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     if (polygonRenderer == null) {
         polygonRenderer = new MKPolygonRenderer (overlay as MKPolygon);
         polygonRenderer.FillColor = UIColor.Red;
         polygonRenderer.StrokeColor = UIColor.Blue;
         polygonRenderer.Alpha = 0.4f;
         polygonRenderer.LineWidth = 9;
     }
     return polygonRenderer;
 }
Esempio n. 34
0
        private MKOverlayRenderer OverlayRendererHandler(MKMapView mapView, IMKOverlay overlayWrapper)
        {
            var overlay = Runtime.GetNSObject(overlayWrapper.Handle) as IMKOverlay;

            return(new MKPolygonRenderer(overlay as MKPolygon)
            {
                StrokeColor = UIColor.Orange,
                FillColor = UIColor.Red.ColorWithAlpha(0.5f),
                LineWidth = 3f
            });
        }
Esempio n. 35
0
        public MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {
            var renderer = new RadarOverlayRenderer(overlay);

            if (overlay is RadarOverlay)
            {
                renderer.RefreshRenderer();
            }

            return(renderer);
        }
Esempio n. 36
0
		public override MKOverlayView GetViewForOverlay (MKMapView mapView, IMKOverlay overlay)
		{
			if (RegionDefinerViewController.PolygonView != null && RegionDefinerViewController.PolygonView.Polygon == RegionDefinerViewController.Polygon)
				return RegionDefinerViewController.PolygonView;

			RegionDefinerViewController.Polygon = overlay as MKPolygon;
			RegionDefinerViewController.PolygonView = new MKPolygonView (RegionDefinerViewController.Polygon) {
				FillColor = new UIColor (0, 1, 0, .3f),
				StrokeColor = new UIColor (0, 1, 0, 0.9f),
				LineWidth = 1.0f
			};

			return RegionDefinerViewController.PolygonView;
		}
			public override MKOverlayView GetViewForOverlay (MKMapView mapView, IMKOverlay overlay)
			{
				var circleOverlay = overlay as MKCircle;
				var circleView = new MKCircleView (circleOverlay);
				circleView.FillColor = UIColor.Red;
				circleView.Alpha = 0.4f;
				return circleView;
			}
        /// <summary>
        /// Get the overlay renderer
        /// </summary>
        /// <param name="mapView">The <see cref="MKMapView"/></param>
        /// <param name="overlay">The overlay to render</param>
        /// <returns>The overlay renderer</returns>
        private MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {

            var polyline = overlay as MKPolyline;
            if (polyline != null)
            {
                // check if this polyline is a route
                var route = this._routes[polyline];
                if (route == null)
                {
                    // not a route, check if it is a line
                    var line = this._lines[polyline];

                    if (line == null) return null;

                    if (line.Renderer == null)
                    {
                        line.Renderer = new MKPolylineRenderer(polyline);
                    }
                    line.Renderer.FillColor = line.Overlay.Color.ToUIColor();
                    line.Renderer.LineWidth = line.Overlay.LineWidth;
                    line.Renderer.StrokeColor = line.Overlay.Color.ToUIColor();

                    // return renderer for the line
                    return line.Renderer;
                }

                if (route.Renderer == null)
                {
                    route.Renderer = new MKPolylineRenderer(polyline);
                }
                route.Renderer.FillColor = route.Overlay.Color.ToUIColor();
                route.Renderer.LineWidth = route.Overlay.LineWidth;
                route.Renderer.StrokeColor = route.Overlay.Color.ToUIColor();
                return route.Renderer;
            }

            var mkCircle = overlay as MKCircle;
            if (mkCircle != null)
            {
                var circle = this._circles[mkCircle];
                if (circle == null) return null;

                if (circle.Renderer == null)
                {
                    circle.Renderer = new MKCircleRenderer(mkCircle);
                }
                circle.Renderer.FillColor = circle.Overlay.Color.ToUIColor();
                circle.Renderer.StrokeColor = circle.Overlay.StrokeColor.ToUIColor();
                circle.Renderer.LineWidth = circle.Overlay.StrokeWidth;
                return circle.Renderer;
            }

            var mkPolygon = overlay as MKPolygon;
            if (mkPolygon != null)
            {
                var polygon = this._polygons[mkPolygon];
                if (polygon == null) return null;

                if (polygon.Renderer == null)
                {
                    polygon.Renderer = new MKPolygonRenderer(mkPolygon);
                }
                
                polygon.Renderer.FillColor = polygon.Overlay.Color.ToUIColor();
                polygon.Renderer.StrokeColor = polygon.Overlay.StrokeColor.ToUIColor();
                polygon.Renderer.LineWidth = polygon.Overlay.StrokeWidth;
                return polygon.Renderer;
            }
            return null;
        }
Esempio n. 39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TreeWatch.iOS.MultiPolygonView"/> class.
 /// </summary>
 /// <param name="overlay">Overlay to be displayed.</param>
 public MultiPolygonView(IMKOverlay overlay)
 {
     this.polygonOverlay = overlay;
 }
        public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {
            var unifiedOverlay = overlay as IUnifiedOverlay;
            if (unifiedOverlay != null)
            {
                return unifiedOverlay.GetRenderer();
            }

            return null;
        }
Esempio n. 41
0
        /* TODO Readd LFHeatMap project first
         * Found at https://github.com/TreeWatch/LFHeatMaps
         * Code:
        void ChangeRegion(object sender, MKMapViewChangeEventArgs e){

            foreach (var item in mapView.Subviews)
            {
                var heatMap = item as UIHeatMapView;
                if (heatMap != null)
                    heatMap.RefreshHeatMap(mapView);
            }
        }
        */

        /// <summary>
        /// Gets the overlay render for a overlay.
        /// </summary>
        /// <returns>The overlay render.</returns>
        /// <param name="m">The Mapview.</param>
        /// <param name="o">The Overlay.</param>
        private MKOverlayRenderer GetOverlayRender(MKMapView m, IMKOverlay o)
        {
            var overlay = Runtime.GetNSObject(o.Handle) as MKPolygon;
            if (overlay != null)
            {
                var polygon = overlay;
                var polygonRenderer = new MKPolygonRenderer(polygon);

                if (polygon.Title == "Field")
                {
                    polygonRenderer.FillColor = this.myMap.OverLayColor.ToUIColor();
                    polygonRenderer.StrokeColor = this.myMap.BoundaryColor.ToUIColor();
                    polygonRenderer.LineWidth = 1;
                }

                return polygonRenderer;
            }

            if (o is MultiPolygon)
            {
                return new MultiPolygonView(o);
            }

            return null;
        }
        public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)
        {
            if (overlay is MKCircle)
            {
                if (circleRenderer == null)
                {
                    circleRenderer = new MKCircleRenderer(overlay as MKCircle);
                    circleRenderer.FillColor = UIColor.Purple;
                    circleRenderer.Alpha = 0.5f;
                }
                return circleRenderer;

            } else if (overlay is MKPolygon)
            {
                if (polyRenderer == null)
                {
                    polyRenderer = new MKPolygonRenderer(overlay as MKPolygon);
                    polyRenderer.FillColor = UIColor.Green;
                    polyRenderer.Alpha = 0.5f;
                }
                return polyRenderer;
            } else
            {
                Debug.WriteLine("OverlayRenderer() - Unknown overlay type!");
                return null;
            }

        }            
			public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
			{
				if ((_circle != null) && (_circleView == null))
				{
					_circleView = new MKCircleView(_circle);
					_circleView.FillColor = UIColor.Blue;
					_circleView.Alpha = 0.5f;
				}
				return _circleView;
			} 
		public RadarOverlayRenderer (IMKOverlay overlay) : base (overlay) { }
		public MKOverlayRenderer OverlayRenderer (MKMapView mapView, IMKOverlay overlay)
		{
			return new MKOverlayPathRenderer (overlay) {
				FillColor = UIColor.Blue.ColorWithAlpha (0.2f),
				StrokeColor = UIColor.Black,
				LineWidth = 2
			};
		}