UWP MapControl MapPolygon笔划设置不正确

问题描述 投票:1回答:1

我将多个MapPolygon放置在一个MapControl上。 MapPolygon的笔划设置不正确。所有多边形的笔触颜色(无论它们位于哪个层)都将绑定到Z指数最高的多边形。我使用Microsoft的UWP MapControl示例创建了一个示例:https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/display-poi请参阅“添加形状”部分。

我尝试将每个多边形放置在单独的图层中,但结果相似。

值得注意的是,Polygon FillColor参数仅不影响笔触颜色和粗细。

XAML

 <my:MapControl HorizontalAlignment="Left" x:Name="mapControl" MapServiceToken="..." Width="1650" Height="800" />

   public BlankPage1()
    {
        this.InitializeComponent();
        BasicGeoposition cityPosition = new BasicGeoposition() { Latitude = 34.8, Longitude = -116, Altitude = 0 };
        Emitter_Position = new Geopoint(cityPosition);

        mapControl.Center = Emitter_Position;
        mapControl.ZoomLevel = 9;
        mapControl.LandmarksVisible = true;
        test_polygons();
    }

    public void test_polygons()
    {
        double centerLatitude = Emitter_Position.Position.Latitude;
        double centerLongitude = Emitter_Position.Position.Longitude;
        var MyHighlights = new List<MapElement>();
        var mapPolygon = new MapPolygon
        {
            Path = new Geopath(new List<BasicGeoposition> {
                new BasicGeoposition() {Latitude=centerLatitude+0.1, Longitude=centerLongitude-0.1 },
                new BasicGeoposition() {Latitude=centerLatitude-0.1, Longitude=centerLongitude-0.1 },
                new BasicGeoposition() {Latitude=centerLatitude-0.1, Longitude=centerLongitude+0.1 },
                new BasicGeoposition() {Latitude=centerLatitude+0.1, Longitude=centerLongitude+0.1 },
            }),
            ZIndex = 2,
            FillColor = Colors.Red,
            StrokeColor = Colors.Blue,
            StrokeThickness = 3,
            StrokeDashed = false,
        };

        var mapPolygon2 = new MapPolygon
        {
            Path = new Geopath(new List<BasicGeoposition> {
                new BasicGeoposition() {Latitude=centerLatitude+0.2, Longitude=centerLongitude-0.2 },
                new BasicGeoposition() {Latitude=centerLatitude-0.2, Longitude=centerLongitude-0.2 },
                new BasicGeoposition() {Latitude=centerLatitude-0.2, Longitude=centerLongitude+0.2 },
                new BasicGeoposition() {Latitude=centerLatitude+0.2, Longitude=centerLongitude+0.2 },
            }),
            ZIndex = 1,
            FillColor = Colors.Green,
            StrokeColor = Colors.Yellow,
            StrokeThickness = 3,
            StrokeDashed = false,
        };

        MyHighlights.Add(mapPolygon);
        MyHighlights.Add(mapPolygon2);
        var HighlightsLayer = new MapElementsLayer
        {
            ZIndex = 1,
            MapElements = MyHighlights
        };
        Result_Map.Layers.Add(HighlightsLayer);

    }

mapPolygon2的笔触颜色显示为蓝色,而不是黄色。如果您enter image description here翻转mapPolygons的Zindex,则两个多边形的笔触将为黄色。那么,显示多个多边形时正确设置笔触的诀窍是什么?

c# uwp bing-maps
1个回答
1
投票

这不会受到您所定位的操作系统版本的影响,而是会受到您所运行的操作系统版本的影响。这是1809年之前的OS版本中的一个已知问题,因此已修复了大约一年。更新到较新版本的OS应该可以解决您的问题。如果无法更新操作系统,建议的解决方法是绘制无边界的多边形,然后在单独的调用中将边界绘制为折线。

© www.soinside.com 2019 - 2024. All rights reserved.