見出しに基づいてビューの緯度と経度のコーナーを計算するためのソリューションはありますか?
見出しが 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;
}