コード例 #1
0
        public MapElementsGallery()
        {
            InitializeComponent();

            Map.MoveToRegion(
                MapSpan.FromCenterAndRadius(
                    new Position(39.828152, -98.569817),
                    Distance.FromMiles(1681)));

            _polyline = new Maps.Polyline
            {
                Geopath =
                {
                    new Position(47.641944, -122.127222),
                    new Position(37.411625, -122.071327),
                    new Position(35.138901, -80.922623)
                }
            };

            _polygon = new Maps.Polygon
            {
                StrokeColor = Color.FromHex("#002868"),
                FillColor   = Color.FromHex("#88BF0A30"),
                Geopath     =
                {
                    new Position(37, -102.05),
                    new Position(37, -109.05),
                    new Position(41, -109.05),
                    new Position(41, -102.05)
                }
            };

            _circle = new Circle
            {
                Center      = new Position(42.352364, -71.067177),
                Radius      = Distance.FromMiles(100.0),
                StrokeColor = Color.FromRgb(31, 174, 206),
                FillColor   = Color.FromRgba(31, 174, 206, 127)
            };

            Map.MapElements.Add(_polyline);
            Map.MapElements.Add(_polygon);
            Map.MapElements.Add(_circle);

            ElementPicker.SelectedIndex = 0;
        }
コード例 #2
0
        void AddClicked(object sender, EventArgs e)
        {
            switch (_selectedType)
            {
            case SelectedElementType.Polyline:
                Map.MapElements.Add(_polyline = new Maps.Polyline());
                break;

            case SelectedElementType.Polygon:
                Map.MapElements.Add(_polygon = new Maps.Polygon());
                break;

            case SelectedElementType.Circle:
                Map.MapElements.Add(_circle = new Circle());
                break;
            }
        }
コード例 #3
0
ファイル: MapViewModel.cs プロジェクト: ReillyM-C/Groundsman
        private void DrawPolygon(Feature feature)
        {
            if (Preferences.Get(Constants.MapDrawPolygonsKey, true))
            {
                XFMPolygon xfmpolygon = new XFMPolygon
                {
                    StrokeWidth = 4,
                    StrokeColor = Color.OrangeRed,
                    FillColor   = Color.OrangeRed.AddLuminosity(.1).MultiplyAlpha(0.6),
                };

                Polygon polygon = (Polygon)feature.Geometry;
                foreach (LineString lineString in polygon.Coordinates)
                {
                    foreach (Position pos in lineString.Coordinates)
                    {
                        xfmpolygon.Geopath.Add(new XFMPosition(pos.Latitude, pos.Longitude));
                    }
                }
                Map.MapElements.Add(xfmpolygon);
            }
        }
コード例 #4
0
        void RemoveClicked(object sender, EventArgs e)
        {
            switch (_selectedType)
            {
            case SelectedElementType.Polyline:
                Map.MapElements.Remove(_polyline);
                _polyline = Map.MapElements.OfType <Maps.Polyline>().LastOrDefault();

                if (_polyline == null)
                {
                    Map.MapElements.Add(_polyline = new Maps.Polyline());
                }

                break;

            case SelectedElementType.Polygon:
                Map.MapElements.Remove(_polygon);
                _polygon = Map.MapElements.OfType <Maps.Polygon>().LastOrDefault();

                if (_polygon == null)
                {
                    Map.MapElements.Add(_polygon = new Maps.Polygon());
                }

                break;

            case SelectedElementType.Circle:
                Map.MapElements.Remove(_circle);
                _circle = Map.MapElements.OfType <Circle>().LastOrDefault();

                if (_circle == null)
                {
                    Map.MapElements.Add(_circle = new Circle());
                }

                break;
            }
        }
コード例 #5
0
        //it's Function for Draw The Polygon By Polygons (it type is FeatureCollection) That Contains Ploygon Coordinates
        private void DrawPolygon()
        {
            for (int i = 0; i < Polygons.Features.Count; i++)
            {
                var coord = ((GeoJSON.Net.Geometry.Polygon)Polygons.Features[i].Geometry).Coordinates;

                var positions = new List <Position>();
                Xamarin.Forms.Maps.Polygon polygon = new Xamarin.Forms.Maps.Polygon
                {
                    StrokeColor = Color.FromHex("#1BA1E2"),
                    StrokeWidth = 8,
                    FillColor   = Color.FromHex("#881BA1E2")
                };
                for (int j = 0; j < coord[0].Coordinates.Count; j++)
                {
                    var _lat  = coord[0].Coordinates[j].Latitude;
                    var _long = coord[0].Coordinates[j].Longitude;
                    positions.Add(new Position(_lat, _long));
                    polygon.Geopath.Add(new Position(_lat, _long));
                }
                map.MapElements.Add(polygon);
            }
        }