public static Point WGS84ToBing(Point coordinate)
{
double d = coordinate.X * Math.PI / 180, m = coordinate.Y * Math.PI / 180, l = 6378137, k = 0.0818191908426, f = k * Math.Sin(m);
double h = Math.Tan(Math.PI / 4 + m / 2), j = Math.Pow(Math.Tan(Math.PI / 4 + Math.Asin(f) / 2), k), i = h / j;
return new Point(l * d, l * Math.Log(i));
}
public static Point BingtoWGS84Mercator(Point point)
{
double lon = (point.X / 20037508.34) * 180;
double lat = (point.Y / 20037508.34) * 180;
lat = 180 / Math.PI * (2 * Math.Atan(Math.Exp(lat * Math.PI / 180)) - Math.PI / 2);
return new Point(lon, lat);
}
使用示例:
HttpMapTileDataSource dataSource = new HttpMapTileDataSource("http://vec02.maps.yandex.net/tiles?l=map&v=2.2.3&x={x}&y={y}&z={zoomlevel}");
MapTileSource tileSource = new MapTileSource(dataSource)
{
Layer = MapTileLayer.BackgroundReplacement
};
map.Style = MapStyle.None;
map.TileSources.Add(tileSource);
Point bingPoint = WGS84ToBing(new Point(47.245252, 56.139498));
Point yandexCoordinates = BingtoWGS84Mercator(new Point(bingPoint.X, bingPoint.Y));
map.Center = new Geopoint(new BasicGeoposition() { Longitude = yandexCoordinates.X, Latitude = yandexCoordinates.Y });