示例#1
0
        private void Map1_Loaded(object sender, RoutedEventArgs e)
        {
            Map1.MapUnit = GeoUnit.Meter;
            Map1.UseOpenStreetMapAsBaseMap();

            GeoBound bound  = new GeoBound(2171997.6512, 8356849.2669, 3515687.9933, 11097616.86);
            GeoPoint center = bound.GetCentroid();
            double   x1     = bound.MinX + bound.Width * .25;
            double   y      = center.Y;
            double   x2     = bound.MaxX - bound.Width * .25;
            double   radius = bound.Width * 3 / 8;

            feature1 = new Feature(new GeoEllipse(new GeoPoint(x1, y), radius));
            feature2 = new Feature(new GeoEllipse(new GeoPoint(x2, y), radius));

            MemoryLayer highlightLayer = new MemoryLayer {
                Name = "HighlightLayer"
            };

            highlightLayer.Features.Add(feature1);
            highlightLayer.Features.Add(feature2);
            highlightLayer.Styles.Add(new FillStyle(GeoColor.FromHtml("#55FAB04D"), GeoColors.White));
            Map1.AddStaticLayers("HighlightOverlay", highlightLayer);

            MemoryLayer resultLayer = new MemoryLayer {
                Name = "ResultLayer"
            };

            resultLayer.Styles.Add(new FillStyle(GeoColor.FromHtml("#99FF5722"), GeoColors.White));
            Map1.AddDynamicLayers("ResultOverlay", resultLayer);

            Map1.ZoomTo(bound);
        }
示例#2
0
        private Feature CreateLineFeature(GeoBound bound)
        {
            GeoLine line = new GeoLine();

            double startX                  = bound.MinX + bound.Width * .15;
            double endX                    = bound.MinX + bound.Width * .85;
            double centerY                 = bound.GetCentroid().Y;
            double height                  = bound.Height * .25;
            int    segmentCount            = 30;
            double segmentHorizontalLength = (endX - startX) / segmentCount;

            for (int i = 0; i < segmentCount; i++)
            {
                double x = startX + segmentHorizontalLength * i;
                double y = Math.Sin(Math.PI * 2 * i / segmentCount) * height + centerY;
                line.Coordinates.Add(new GeoCoordinate(x, y));
            }

            return(new Feature(line));
        }
示例#3
0
        private void Map1_MapSingleClick(object sender, MapClickEventArgs e)
        {
            Feature identifiedFeature = IdentifyHelper.Identify(dataLayer, e.WorldCoordinate, Map1.CurrentScale, Map1.MapUnit).FirstOrDefault();

            if (identifiedFeature != null)
            {
                MemoryLayer highlightLayer = Map1.FindLayer <MemoryLayer>("HighlightLayer");

                highlightLayer.Features.Clear();
                highlightLayer.Features.Add(identifiedFeature);

                GeoBound identifiedBound = identifiedFeature.GetBound();
                highlightLayer.Features.Add(new Feature(new GeoLine(identifiedBound.GetVertices())));

                GeoPoint identifiedCenter = identifiedBound.GetCentroid();
                highlightLayer.Features.Add(new Feature(identifiedCenter));

                Map1.Refresh("HighlightOverlay");
            }
        }