【发布时间】: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
...
MapTileBitmapRequestedEventArgs 的 X 和 Y 是 Tile 的 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