首页 > 解决方案 > UWP MapControl 抗锯齿属性在哪里?

问题描述

我使用UWP MapControl并添加了一些MapPolylines. 而且它们看起来很丑(见下图) 在此处输入图像描述

我认为应该是一种财产,但在这里antialiasing找不到。

请帮忙,谢谢!

C#

var mapPolyline = new MapPolyline();
var geoPositions = new List<BasicGeoposition>();
foreach (var vertex in polyLine.Vertex)
{
  // adding BasicGeopositions...
};
mapPolyline.StrokeColor = Colors.Black;
mapPolyline.StrokeThickness = 1;
mapPolyline.Path = new Geopath(geoPositions);
((MapElementsLayer)impotMapLayer).MapElements.Add(mapPolyline);

更新#1基于答案

我研究了这篇文章 “在地图上叠加平铺图像”以及这篇文章"MapTileBitmapRequestedEventArgs Class",但无法获得 X 和 Y 的明确定义"MapTileBitmapRequestedEventArgs Class"

文章说

X   Gets the X value of the requested tile.
Y   Gets the Y value of the requested tile.

从这里使用 MSDN 示例, 我得到以下X、Y、Zoom的日志

X 6073  Y 2617 Zoom 13
X 6072  Y 2616 Zoom 13
X 6071  Y 2615 Zoom 13
X 6071  Y 2617 Zoom 13
X 6072  Y 2614 Zoom 13
X 6073  Y 2615 Zoom 13
X 6071  Y 2616 Zoom 13
X 6073  Y 2614 Zoom 13
X 6072  Y 2615 Zoom 13
    
    and etc

如果我只想创建平铺图像,你介意澄清一下这些数字到底是什么,以及我如何将它与内存中顶点的地理位置集相关联,好吗?(我的折线集已经在地理点中计算了。)

非常感谢!

更新 #2 这是解决方案

首先我读了这篇文章https://docs.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system?redirectedfrom=MSDN

所以我们需要TileSystem进行一系列转换

namespace Microsoft.MapPoint 
{  
    static class TileSystem  
...

XYMapTileBitmapRequestedEventArgs 我们必须传递给Tile 的XYTileSystem.TileXYToPixelXY(args.X, args.Y, out int pixelX, out int pixelY);

最终代码基于https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/overlay-tiled-images

private async void customDataSource_BitmapRequestedAsync(CustomMapTileDataSource sender, MapTileBitmapRequestedEventArgs args)
{
    var deferral = args.Request.GetDeferral();
             
            
    TileSystem.TileXYToPixelXY(args.X, args.Y, out int pixelX, out int pixelY);
                    
    TileSystem.PixelXYToLatLong(pixelX, pixelY,  args.ZoomLevel, out double  lat, out double lng);
    
    Debug.WriteLine($"lat {lat}  lng {lng} Zoom {args.ZoomLevel}");
    
    // next step is to extract from my custom array polylines accroding to   TileSystem.PixelXYToLatLong

    // and finally pass it inside of CreateBitmapAsStreamAsync(array to draw);
    
    args.Request.PixelData = await CreateBitmapAsStreamAsync(array to draw);
                         
    deferral.Complete();
}

标签: c#uwpantialiasinguwp-mapsuwp-mapcontrol

解决方案


目前 MapPolylines 是在没有抗锯齿的情况下绘制的,并且没有设置来更改该行为。查看您的屏幕截图,使用自定义切片图层可能会更好地为您服务。请参阅此处的 CustoMapTileDatasource:https ://docs.microsoft.com/en-us/windows/uwp/maps-and-location/overlay-tiled-images 您可以使用您喜欢的任何方法在回调中绘制每个图块,包括抗锯齿。对于大量静态线(例如您的示例中的地形轮廓),它​​也往往会表现得更好


推荐阅读