GilShalit
GilShalit

Reputation: 6473

with openlayers , how do i make sure a list of points are all displayed?

I have an OpenLayers map object, and I have added markers to a layer, and added it to the map.

But how do I make sure all the markers are in the display area?

Thanks,

Gil

Upvotes: 1

Views: 2196

Answers (1)

Myra
Myra

Reputation: 3656

In order to display all markers on the map
Firstly,make sure you have all markers in one layer.
Secondly,you need to zoom to bound where all markers in marker layer are extended.
To do that,simply

   var bounds = markerLayer.getDataExtent();
   map.zoomToExtent(bounds);
   //has a second parameter that decides to find closest zoom level
   //default is false

Please check OpenLayers Document for Marker Layer

Best Regards
Myra

Upvotes: 7

Related Questions