【发布时间】:2016-11-06 18:35:08
【问题描述】:
我想通过将硬编码的偏移值替换为一个函数来旋转多边形(例如这个箭头),在该函数中可以传入北指向偏移和我希望箭头旋转的度数。强>
我尝试使用Rotation matrix,但效果不佳。
大概是因为距离
1 纬度!= 1 长。
我想用这个做什么:
箭头必须代表车辆并沿车辆前进的方向旋转。
double centerLatitude = pos.Coordinate.Point.Position.Latitude;
double centerLongitude = pos.Coordinate.Point.Position.Longitude;
MapPolygon mapPolygon = new MapPolygon();
mapPolygon.Path = new Geopath(new List<BasicGeoposition>() {
new BasicGeoposition() {Longitude=centerLongitude, Latitude=centerLatitude},//top of the arrow
new BasicGeoposition() {Longitude=centerLongitude-0.001, Latitude=centerLatitude-0.0010},
new BasicGeoposition() {Longitude=centerLongitude-0.001, Latitude=centerLatitude-0.0030},
new BasicGeoposition() {Longitude=centerLongitude+0.001, Latitude=centerLatitude-0.0030},
new BasicGeoposition() {Longitude=centerLongitude+0.001, Latitude=centerLatitude-0.0010},
});
mapPolygon.ZIndex = 1;
mapPolygon.FillColor = Colors.Orange;
mapPolygon.StrokeColor = Colors.Blue;
mapPolygon.StrokeThickness = 2;
mapPolygon.StrokeDashed = false;
MainMap.MapElements.Add(mapPolygon);
【问题讨论】:
-
不是确切的答案,但可能会有所帮助:您可以将您的问题视为如何在线端绘制箭头帽的问题的变体。纬度/经度将是 X/Y,您的多边形将是箭头。有一个很好的post about that on math.stackexchange也许你可以根据你的具体情况调整这些想法。
-
您是否考虑过使用 xaml 控件而不是 mapPolygon?例如。带箭头的图像控件,会容易得多。
-
我尝试使用地图图标,但它不想随地图旋转。
标签: c# rotation uwp rotatetransform uwp-maps