Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Predicting zoomlevel before this.map.fitBounds

Tags:

leaflet

mapbox

I am using mapbox in our application. Doing this.map.fitBounds(bound value) will zoomout or zoomin map to bound specified value. I need to find out zoom level (i.e map rendering after fit bounds) before calling this.map.fitBounds. Is there any methods available in mapbox?

like image 896
Jeevan Roy dsouza Avatar asked Oct 19 '15 08:10

Jeevan Roy dsouza


1 Answers

Use L.Map's getBoundsZoom method:

Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety.

http://leafletjs.com/reference.html#map-getboundszoom

like image 185
iH8 Avatar answered Nov 13 '22 23:11

iH8