Esempio n. 1
0
        private void DrawPolygon()
        {
            PolygonOptions polygonOptions = GetPolygoneRenderer();

            foreach (var position in _shapeCoordinates)
            {
                polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }
            _polygon = NativeMap.AddPolygon(polygonOptions);
        }
Esempio n. 2
0
        protected Polygon GetFormsPolygon(APolygon polygon)
        {
            Polygon targetPolygon = null;

            for (int i = 0; i < Element.MapElements.Count; i++)
            {
                var element = Element.MapElements[i];
                if ((string)element.MapElementId == polygon.Id)
                {
                    targetPolygon = (Polygon)element;
                    break;
                }
            }

            return(targetPolygon);
        }
Esempio n. 3
0
        private void AddPolygonGeometryToMap(GPolygon polygonGeometry)
        {
            PolygonOptions polygon = GeoJsonPolygonToPolygon(polygonGeometry);

            if (polygon != null)
            {
                try
                {
                    APolygon aPolygon = NativeMap.AddPolygon(polygon);
                    _polygons.Add(polygonGeometry, aPolygon);
                }
                catch (Exception)
                {
                    Console.WriteLine("Failed to add polygon to map or dictionary");
                }
            }
        }
Esempio n. 4
0
        protected APolygon GetNativePolygon(Polygon polygon)
        {
            APolygon targetPolygon = null;

            if (_polygons != null)
            {
                for (int i = 0; i < _polygons.Count; i++)
                {
                    var native = _polygons[i];
                    if (native.Id == (string)polygon.MapElementId)
                    {
                        targetPolygon = native;
                        break;
                    }
                }
            }

            return(targetPolygon);
        }
		/// <summary>
		/// Replaces the already visible zone or creates a new one.
		/// </summary>
		/// <param name="z">The z coordinate.</param>
		/// <param name="replace">The z coordinate.</param>
		void CreateZone (Zone z, Polygon replace = null)
		{
			IList<LatLng> points = new List<LatLng>(z.Points.Count);
			if (replace != null) {
				// Replace the points from the old polygon
				foreach (var zp in z.Points) {
					points.Add(new LatLng(zp.Latitude, zp.Longitude));
					replace.Points = points;
				}
			} else {
				// Create a new polygon for zone
				PolygonOptions po = new PolygonOptions ();
				foreach (var zp in z.Points) {
					po.Points.Add (new LatLng (zp.Latitude, zp.Longitude));
				}
				po.InvokeStrokeColor (Color.Argb (160, 255, 0, 0));
				po.InvokeStrokeWidth (2);
				po.InvokeFillColor (Color.Argb (80, 255, 0, 0));
				po.InvokeZIndex(1);

				// Add polygon to list of active zones
				zones.Add (z.ObjIndex, _map.AddPolygon (po));
			}
		}
Esempio n. 6
0
        private void HandleMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
        {
            ClearMapOverlays ();
            Marker marker = e.Marker;
            int index = int.Parse (marker.Title);
            extendedMap.pin_Clicked (index );

            Android.Graphics.Color clrb = new Android.Graphics.Color (12,92,169,130);
            Android.Graphics.Color clrr = new Android.Graphics.Color (204,27,39,130);
            PolygonOptions polygonOptions = new PolygonOptions();
            switch (index)
            {
            case 0:
                CircleOptions circleOptions = new CircleOptions ();
                circleOptions.InvokeCenter (new LatLng (extendedMap.pinDatas [index].lat, extendedMap.pinDatas [index].lng));
                circleOptions.InvokeRadius (2000);

                circleOptions.InvokeFillColor (clrb.ToArgb ());
                circleOptions.InvokeStrokeColor (clrr.ToArgb ());

                circle = map.AddCircle (circleOptions);

                break;
            case 1:
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng+0.01));
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng+0.01));
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng-0.01));
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng-0.01));
                polygonOptions.InvokeFillColor (clrb.ToArgb());
                polygonOptions.InvokeStrokeColor (clrr.ToArgb());
                polygon = map.AddPolygon(polygonOptions);
                break;
            case 2:
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng+0.01));
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng+0.01));
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.005, extendedMap.pinDatas[index].lng));
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.02, extendedMap.pinDatas[index].lng-0.02));
                polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng-0.01));
                polygonOptions.InvokeFillColor (clrb.ToArgb());
                polygonOptions.InvokeStrokeColor (clrr.ToArgb());
                polygon = map.AddPolygon(polygonOptions);
                break;
                default:
                CircleOptions circleOptions2 = new CircleOptions ();
                circleOptions2.InvokeCenter (new LatLng (extendedMap.pinDatas [index].lat, extendedMap.pinDatas [index].lng));
                circleOptions2.InvokeRadius (2000);

                circleOptions2.InvokeFillColor (clrb.ToArgb ());
                circleOptions2.InvokeStrokeColor (clrr.ToArgb ());

                circle = map.AddCircle (circleOptions2);

                break;
            }
        }