I need to change zoom level dynamically in openstreet map according to displayed number of markers, means if there is only one location is marked i need more zoom and if there is more than one locations are marked i need zoom level is less( because i want to see all markers).I'm using OpenLayers library. Can any one help me..? Thanks in adavace... asked 31 Jul '12, 05:57 pramod_ck SomeoneElse ♦ |
This is more an OpenLayers question than an OpenStreetMap question. See openlayers.org for means to get help. What you probably want to do is use OpenLayers' "zoomToExtent" function, using an extent that you have created with reference to the sum of all your markers. answered 31 Jul '12, 10:10 Frederik Ramm ♦ @Frederik Ramm, Thanks. Actually i'm very new to this.. So first i need to define the bounds right..?
(31 Jul '12, 10:25)
pramod_ck
|
You can take a look at this other question. For zooming on your markers (the zoom will automatically be computed), you have to invoke zoomToExtent as said Frederik: map.zoomToExtent(markersLayer.getDataExtent()); answered 28 Aug '12, 12:40 NicolasDumoulin |
I'm guessing that you're using a Javascript library to display OpenStreetMap tiles (perhaps one of the ones mentioned here)?
A bit more information about what you're trying to do would help.
ya, I'm using OpenLayers library only. The problem is we want to display several markers on a map and want to calculate the optimal zoom-level like Google Maps does. We already calculated the centerpoint of the map but now we have a hard time to calculate the correct zoomlevel to display the whole markers..
Which javascript library? OpenLayers or Leaflet? (you should edit your question to supply more details)
I'm using OpenLayers library..