문제

I am using VEMap API. I have the latitude and longitude of the top left point and the bottom right point (bounding box) of a map. I want to get the center point. What is an easy way to do that? I couldn't find a solution by searching on Google.

What I was thinking is that if I can define the map using the two points mentioned above, then I can get the center very easily:

// JavaScript code snippet
var center = map.GetCenter();
var lat = center.Latitude;
var lng = center.Longitude;

Is there a way to call the constructor of map object and pass the two coordinates I have?

Thanks.

도움이 되었습니까?

해결책

The simple answer would be add the latitudes and divide by two, and do the same for longitudes. They are straight lines.

다른 팁

Is there any reason you can't use the VEMap.GetCenter method after the map has been constructed? This way regardless of the viewpoint it will be correct. If you're using the default constructor you can pass in your bounding box, and then call getmap after the object is instantiated.

http://msdn.microsoft.com/en-us/library/bb412539.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top