有没有人有根据航向计算视图的纬度和经度角的解决方案?
如果标题为 0,我有一个计算视图的 LatLng 角的函数。但我希望找到一种方法来计算基于新标题的角,例如,如果用户旋转地图。
我现在使用 Heading = 0 执行此操作的代码是这样的。
public GeoboundingBox GetBounds(MapControl map)
{
if(map.Center.Position.Latitude == 0) { return default(GeoboundingBox); }
/*
* resolution m/px = 15653.04 m/px * Cos(LatInRad) / 2^zoomLevel
* 111325 m/deg
*/
double latInRad = Math.Cos(map.Center.Position.Latitude * Math.PI / 180);
double lngInRad = Math.Cos(map.Center.Position.Longitude * Math.PI / 180);
double degreePerPixel = (156543.04 * latInRad * lngInRad) / (111325 * Math.Pow(2, map.ZoomLevel));
double mHalfWidthInDegrees = map.ActualWidth * degreePerPixel / 0.89;
double mHalfHeightInDegrees = map.ActualHeight * degreePerPixel / 1.65;
double mNorth = map.Center.Position.Latitude + mHalfHeightInDegrees;
double mWest = map.Center.Position.Longitude - mHalfWidthInDegrees;
double mSouth = map.Center.Position.Latitude - mHalfHeightInDegrees;
double mEast = map.Center.Position.Longitude + mHalfWidthInDegrees;
GeoboundingBox mBounds = new GeoboundingBox(
new BasicGeoposition()
{
Latitude = mNorth,
Longitude = mWest
},
new BasicGeoposition()
{
Latitude = mSouth,
Longitude = mEast
});
return mBounds;
}