c# - 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
...
X和Y是MapTileBitmapRequestedEventArgs
我们必须传递给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();
}
解决方案
目前 MapPolylines 是在没有抗锯齿的情况下绘制的,并且没有设置来更改该行为。查看您的屏幕截图,使用自定义切片图层可能会更好地为您服务。请参阅此处的 CustoMapTileDatasource:https ://docs.microsoft.com/en-us/windows/uwp/maps-and-location/overlay-tiled-images 您可以使用您喜欢的任何方法在回调中绘制每个图块,包括抗锯齿。对于大量静态线(例如您的示例中的地形轮廓),它也往往会表现得更好
推荐阅读
- c++ - 在 C++ 中包装 fortran 函数:带有 LAPACK 的犰狳
- excel - EXCEL - Evaluate() 中使用的公式总是返回 VarType 10(错误),当它在单元格中运行良好时
- sapui5 - 是否可以在 UI5 中的片段加载(从另一个视图)上执行一个方法(最好是 onInit 方法)?
- django - 从视图中调用管理命令并创建文件
- c# - dotNetRDF Reasoners 是否打算以这种方式使用?
- c# - 嵌套列表对象上的 Lambda 查询
- loops - Tableau Prep 中是否有循环功能?(问题写在下面)
- reactjs - React Native 中的 Redux persistReducer 导致极慢的反应时间
- php - 如何在php中生成格式正确的json?
- javascript - React 上的 EditorJS