Bing Maps 8 Map Bounds

The not-yet released Bing Maps 8 library will have a ton of new features. I’ve been experimenting with a pre-release version.

One of the biggest changes is that BM8 has a lot more interactive functionality. If a user is interacting with a map (typically clicking on an object on the map), in many scenarios it’s important to know the latitude and longitude of the four sides that create the map boundary.

The key JavaScript function is named getBounds(). Interestingly, instead of directly returning the boundaries of the map, function getBounds() returns three values: the lat-lon of the center of the map, the total width of the map measured in degrees, and the total height of the map measured in degrees.


Once you have the bounds-object, you can get the NW and SE corners using getNorthwest() and getSoutheast() functions. And you can get the north and south latitudes using getNorth() and getSouth() (and similarly for the east and west longitudes).

I calculated the width of the map by creating a SW corner, and then feeding SE and SW to the getDistanceTo() function of the SpatialMath module (after remembering to load the module).


This entry was posted in Machine Learning, Miscellaneous. Bookmark the permalink.