[英]How to rotate a polygon on a map with the long/lat coordinates?
我想通過用函數傳遞硬編碼的偏移量值來旋轉多邊形(例如,此箭頭),該函數可以傳遞標准的指向偏移量和我希望箭頭旋轉的度數。
我嘗試使用旋轉矩陣,但效果不佳。
可能是因為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);
MapPolygons綁定到地圖上的坐標。 UWP中的旋轉變換不適用於MapPolygons。 如果要旋轉MapPolygon,則必須計算旋轉的坐標。 Bing Maps V8地圖控件(Web)提供了執行此操作的功能。 這是執行此操作的兩種不同方式:
空間上准確(由於地圖投影可能看起來不一樣)
像素精確(與旋轉像素相同,但在空間上不准確)
嘗試執行的最佳方法是使用XAML元素,並將其作為子元素添加到地圖控件中。 您可以將XAML固定在地圖的某一點(箭頭的頭部或中心)。 嘗試更新多邊形的每一幀都不會很快或很平滑,因此您真的不想使用地圖多邊形。 上面建議的某些鏈接假設地圖始終在墨卡托投影中並且向北,並且不傾斜,這對於UWP地圖並不總是正確的,因此,我不建議您采用這種方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.