c# - UWP MapControl MapPolygon 描边设置不正确

标签 c# uwp bing-maps

我正在 MapControl 上放置多个 MapPolygon。 MapPolygons 的笔划设置不正确。所有多边形的描边颜色,无论它们位于哪个图层,都会绑定(bind)到具有最高 Z 索引的多边形。我使用 Microsoft 的 UWP MapControl 示例创建了一个示例: https://learn.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,两个多边形的描边都将为黄色。那么在显示多个多边形时如何正确设置笔画呢?

最佳答案

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

关于c# - UWP MapControl MapPolygon 描边设置不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58202295/

相关文章:

google-maps - 通过 HttpRequest 进行批量地理编码

jquery - 使用 Bing map REST 控件查找附近的实体

c# - 当 Directory.GetFiles() 被拒绝访问时忽略文件夹/文件

c# - 在带有服务器控件的页面上使用 LoadControl

c# - 四舍五入到最接近的五

c# - 如何保存应用程序设置?

c# - ViewModel 中的操作以及 xaml.cs 文件中的操作

c# - UWP - 绑定(bind)数据不起作用 - 空 ListView

c# - ForEach lambda 表达式可以有可选的返回类型吗

wpf - 如何使用 MVVM 在 WPF 中绑定(bind)图钉位置?