Mat*_*Mis 2 c# rotatetransform rotation uwp uwp-maps
我想通过用一个函数替换硬编码的偏移值来旋转多边形(例如这个箭头),该函数可以传入北向偏移和我希望箭头旋转的度数。
我尝试使用旋转矩阵,但效果不佳。
可能是因为 1 Lat 的距离。!= 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);
Run Code Online (Sandbox Code Playgroud)
MapPolygons 绑定到地图上的坐标。UWP 中的旋转变换不适用于 MapPolygons。如果要旋转 MapPolygon,则必须计算旋转后的坐标。Bing Maps V8 地图控件 (web) 提供了执行此操作的功能。这是它执行此操作的两种不同方式:
空间准确(由于地图投影可能看起来不一样)
像素准确(在旋转时看起来相同,但在空间上不准确)