OpenStreetMap and OpenLayers have multiple markers on the map.
The position of this marker varies, so I would like to make it like the Google Maps API fitBounds
method so that all markers can be seen when the map is displayed.
Does OpenLayers offer these features? I looked for it, but I couldn't find it.
Please let me know if there are any alternatives.
javascript openstreetmap openlayers
I think it will be like this.
var bound=new OpenLayers.Bounds();
for (marker: yourMarkers) {
bound.extend(marker.lonlat.transform(your_projection)));
}
map.zoomToExtent (bound);
© 2024 OneMinuteCode. All rights reserved.