マップの上部の緯度、マップの下部の経度 (可視領域)、経度と同じですが、左/右は明らかです。
初心者の「答えを教えてください」のような質問で申し訳ありませんが、これを行う方法がまったくわかりません。
マップの上部の緯度、マップの下部の経度 (可視領域)、経度と同じですが、左/右は明らかです。
初心者の「答えを教えてください」のような質問で申し訳ありませんが、これを行う方法がまったくわかりません。
UWP で mapControl の視点を見つけるコードを作成しました。
https://social.msdn.microsoft.com/Forums/windowsapps/en-us/4e5398de-ec50-46df-84d5-087dcaa20924/wp8-map-viewchanged-and-viewching-events-extents?forum=wpdevelopの元のソース
楽しみ
public GeoboundingBox GetBounds(MapControl map)
{
if(map.Center.Position.Latitude == 0) { return default(GeoboundingBox); }
double degreePerPixel = (156543.04 * Math.Cos(map.Center.Position.Latitude * Math.PI / 180)) / (111325 * Math.Pow(2, map.ZoomLevel));
double mHalfWidthInDegrees = map.ActualWidth * degreePerPixel / 0.9;
double mHalfHeightInDegrees = map.ActualHeight * degreePerPixel / 1.7;
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
});
Debug.WriteLine("New Bounds: NW = " + mNorth + ":" + mWest + " SE = " + mSouth + ":" + mEast);
return mBounds;
}
この関数に欠けているのは、ユーザーが地図を回転させた場合の見出しの計算です。誰かがこれに対する解決策を持っていますか?
コード:
public LocationRectangle GetVisibleMapArea(Map mMap)
{
GeoCoordinate mCenter = mMap.Center;
Point pCenter = mMap.ConvertGeoCoordinateToViewportPoint(mCenter);
GeoCoordinate topLeft = MapVieMode.ConvertViewportPointToGeoCoordinate(new Point(0, 0));
GeoCoordinate bottomRight = MapVieMode.ConvertViewportPointToGeoCoordinate(new Point(MapVieMode.ActualWidth, MapVieMode.ActualHeight));
if (topLeft != null && bottomRight != null)
{
Point pNW = new Point(pCenter.X - mMap.ActualWidth / 2, pCenter.Y - mMap.ActualHeight / 2);
Point pSE = new Point(pCenter.X + mMap.ActualWidth / 2, pCenter.Y + mMap.ActualHeight / 2);
if (pNW != null && pSE != null)
{
GeoCoordinate gcNW = mMap.ConvertViewportPointToGeoCoordinate(pNW);
GeoCoordinate gcSE = mMap.ConvertViewportPointToGeoCoordinate(pSE);
return new LocationRectangle(gcNW, gcSE);
}
}
return null;
}
ここの例から抜粋: http://code.msdn.microsoft.com/wpapps/Windows-Phone-8-Map-0ca7bd6c