UWP MapControl 抗锯齿属性在哪里? [英] Where is UWP MapControl antialiasing property?

查看:33
本文介绍了UWP MapControl 抗锯齿属性在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 UWP MapControl 并添加了一些 MapPolylines.而且它们看起来很丑(见下图)

I work with UWP MapControl and adding some MapPolylines. And they looks ugly (see pic below)

我认为应该是一种 antialiasing 属性,但找不到它此处.

I assume should be kind of antialiasing property but cannot find it 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

我调查了这篇文章在地图上叠加平铺图像" 以及这个"MapTileBitmapRequestedEventArgs Class"并不能得到"MapTileBitmapRequestedEventArgs Class"

I have investigated this article "Overlay tiled images on a map" and also this one "MapTileBitmapRequestedEventArgs Class" and cannot get the clear definition of the X and Y of "MapTileBitmapRequestedEventArgs Class"

文章说

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

使用来自 here 我得到以下 X、Y、Zoom

Using MSDN example from here I get following log for 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

如果我只想创建平铺图像,您是否介意澄清这些数字究竟是什么以及我如何将其与内存中的地理定位顶点集相关联?(我的折线集已经在地理点中计算出来了.)

Would you mind clarify what those numbers are exactly and how I can associate it with geolocations set of vertices in memory if I want create tile-image only, please? (My polylines set already calculated in geopoints.)

非常感谢!

更新 #2 这是解决方案

UPDATE #2 Here is the solution

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

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

So we need TileSystem to make series of convertions

namespace Microsoft.MapPoint 
{  
    static class TileSystem  
...

MapTileBitmapRequestedEventArgsXY 是我们必须传递给TileSystem 的Tile 的XY.TileXYToPixelXY(args.X, args.Y, out int pixelX, out int pixelY);

The X and Y of MapTileBitmapRequestedEventArgs are Tile's XY we have to pass to 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();
}

推荐答案

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

Currently MapPolylines are drawn without antialiasing and there is no setting to change that behavior. Looking at your screenshot, you may be better served by using a custom tile layer. See CustoMapTileDatasource here: https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/overlay-tiled-images You can draw each tile in a callback using whatever method you like including antialiasing. It will also tend to perform better for a large collection of static lines like the topographic contours in your example

这篇关于UWP MapControl 抗锯齿属性在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆