【问题标题】:Where is UWP MapControl antialiasing property?UWP MapControl 抗锯齿属性在哪里?
【发布时间】:2021-08-27 09:01:01
【问题描述】:

我与UWP MapControl 合作并添加了一些MapPolylines。 而且它们看起来很丑(见下图)

我认为应该是antialiasing 的一种属性,但找不到它here

请帮忙,谢谢!

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

我已经调查了这篇文章"Overlay tiled images on a map" 并且还 这个"MapTileBitmapRequestedEventArgs Class",无法得到"MapTileBitmapRequestedEventArgs Class"的X和Y的明确定义

文章说

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

使用来自 here 的 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  
...

MapTileBitmapRequestedEventArgsXYTile 的 XY 我们必须传递给 TileSystem.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# uwp antialiasing uwp-maps uwp-mapcontrol


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      • 2011-07-05
      • 2014-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多