VirtualEarth: determine min/max visible latitude/longitude

旧时模样 提交于 2019-12-23 04:07:13

问题


Is there an easy way to determine the maximum and minimum visible latitude and longitude in a VirtualEarth map? Given that it's not a flat surface (VE uses Mercator projection it looks like) I can see the math getting fairly complicated, I figured somebody may know of a snippet to accomplish this.


回答1:


Found it! VEMap.GetMapView() returns the bounding rectangle, even works for 3D mode as well (where the boundary is not even a rectangle).

var view = map.GetMapView();

latMin = view.BottomRightLatLong.Latitude;
lonMin = view.TopLeftLatLong.Longitude;
latMax = view.TopLeftLatLong.Latitude;
lonMax = view.BottomRightLatLong.Longitude;



回答2:


Using the Virtual Earth Interactive SDK, you can see how to convert a pixel point to a LatLong object:

function GetMap()
{
  map = new VEMap('myMap');
  map.LoadMap();
}

function DoPixelToLL(x, y)
{
  var ll = map.PixelToLatLong(new VEPixel(x, y)).toString()
  alert("The latitude,longitude of the pixel at (" + x + "," + y + ") is: " + ll)
}

Take a further look here: http://dev.live.com/virtualearth/sdk/ in the menu go to: Get map info --> Convert pixel to LatLong

To get the Max/Min visible LatLong's, you could call the DoPixelToLL method for each corner of the map.



来源:https://stackoverflow.com/questions/587047/virtualearth-determine-min-max-visible-latitude-longitude

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!