set map to show all markers

3 posts / 0 new
Last post
david@geowiz.biz
set map to show all markers

Hello, I am switching over to MapQuest because foogle's new pricing is a disaster. In foogle maps i can use bounds to zoom and center the map to make sure all markers are visible on load. I have looked but can't find anythign similar with mapquest can someone point me in the right direction please.


MQBrianCoakley
I'm not aware of a method to
I'm not aware of a method to create a Leaflet map with a bounding box. You'll need to create the map first so Leaflet can figure the bounds depending on the map div size and the featureGroup bounds.

Thomas.Horacek
You will want to use a
You will want to use a FeatureGroup in combination with getBounds. https://leafletjs.com/reference-1.3.2.html#featuregroup-getbounds.  LatLngBounds have a getCenter function. https://leafletjs.com/reference-1.3.2.html#latlngbounds. You will then have to do some data transformation to convert Leaflet bounds to MapQuest formatted bounds but you should get the zoom level from L.mapquest.util.getZoomFromBoundingBox() https://developer.mapquest.com/documentation/mapquest-js/v1.3/l-mapquest...