We want to display several markers on a static map and want to calculate the optimal zoom-level like Google Maps does. We already calculated the bounding rectangle and the centerpoint of the map but now we have a hard time to calculate the correct zoomlevel to display the whole bounding rectangle. Can someone please point us into the right direction?
Tell me more
×
Geographic Information Systems Stack Exchange is a question and answer site for
cartographers, geographers and GIS professionals. It's 100% free, no registration required.
|
|
To get the zoom level, you'll need to know the pixel dimensions of your map. You'll also need to do your math in spherical mercator coordinates.
|
|||||||
|
|
This is the C# code I use in Maperitive:
Note that in my case Of course, this code only applies to Web Mercator projection. |
|||
|
|
|
If you are using OpenLayers then
|
|||
|
|