Exemplo n.º 1
0
        private void AddPolygon_Click(object sender, RoutedEventArgs e)
        {
            ////Sample Polygon added to the map
            //ConfigShapeLayer();
            //var points = new List<Point> {new Point(0, 0), new Point(20, 0), new Point(20, 20), new Point(0, 20)};
            //var polygon = new Polygon {Points = points};
            //shapeLayer.Add(polygon);

            if (shapeLayer == null)
            {
                shapeLayer = new GeometryLayer(MapInstance) { ID = "POLYGONLAYER" };
                shapeLayer.UpdateMode = GeometryLayer.UpdateModes.PanOnlyUpdate; //Old Method
                //shapeLayer.UpdateMode = GeometryLayer.UpdateModes.TransformUpdate;
                shapeLayer.Opacity = 0.4;

                MapInstance.Layers.Insert(1, shapeLayer);
            }

            var points = new ObservableCollection<Point> { new Point(0, 0), new Point(20, 0), new Point(20, 20), new Point(0, 20) };
            //var polygon = new Polygon(shapeLayer) { Points = points };
            var polygon = new Polygon() { Points = points };
            polygon.FillColor = Colors.Green;
            shapeLayer.Add(polygon);

            var linePoints = new ObservableCollection<Point> { new Point(-88, 42), new Point(-75, 39) };
            //LineString line = new LineString(shapeLayer) { Points = linePoints };
            LineString line = new LineString() { Points = linePoints };
            line.LineThickness = 4;
            line.LineColor = Colors.White;
            shapeLayer.Add(line);

            //Add points at each end of the
            shapeLayer.Add(new PointBase { Point = new Point(-88, 42) });
            shapeLayer.Add(new PointBase { Point = new Point(-75, 39) });
            //new PointBase(shapeLayer) { Point = new Point(-88, 42) };
            //new PointBase(shapeLayer) { Point = new Point(-75, 39) };
        }
Exemplo n.º 2
0
        private void GeometryLayerTest()
        {
            //Bermuda Triangle is drawn on a GeometryLayer with TransformUpdate
            GeometryLayer transformLayer = new GeometryLayer(map) { UpdateMode = GeometryLayer.UpdateModes.TransformUpdate };
            transformLayer.Opacity = 0.5;
            map.Layers.Add(transformLayer);
            Polygon polygon = new Polygon();
            transformLayer.Add(polygon);
            polygon.Points = new ObservableCollection<Point> { new Point(-80.195, 25.775), new Point(-64.75, 32.303), new Point(-66.073, 18.44) };
            polygon.FillColor = Color.FromArgb(0x7F, 0xFF, 0x00, 0x00);
            System.Windows.Controls.ToolTipService.SetToolTip(polygon, "Bermuda Triangle");

            //Equator is drawn on a PanOnly GeometryLayer
            GeometryLayer panOnlyLayer = new GeometryLayer(map) { UpdateMode = GeometryLayer.UpdateModes.PanOnlyUpdate };
            panOnlyLayer.Opacity = 0.5;
            map.Layers.Add(panOnlyLayer);
            LineString line = new LineString();
            panOnlyLayer.Add(line);
            line.Points.Add(new Point(-180, 0));
            line.Points.Add(new Point(180, 0));
            line.LineThickness = 4;
            line.LineColor = Colors.White;
            System.Windows.Controls.ToolTipService.SetToolTip(line, "Equator");

            //Equator endpoints are drawn on an ElementUpdate Geometry Layer to test synching of layers
            GeometryLayer elementUpdateLayer = new GeometryLayer(map) { UpdateMode = GeometryLayer.UpdateModes.ElementUpdate };
            elementUpdateLayer.Opacity = 0.5;
            map.Layers.Add(elementUpdateLayer);
            elementUpdateLayer.Add(new PointBase { Point = new Point(-180, 0) });
            elementUpdateLayer.Add(new PointBase { X = 180, Y = 0 }); // Alternative syntax for setting a PointBase
        }