Question

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.

Était-ce utile?

La solution

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top