Reputation: 673
How can i avoid zoomout on this.map.fitBounds()? Doing this.map.fitBounds will zoom in or zoom out map for fitting bound values. I want to avoid zoomout functionality for fitBounds. How i can do like that?
Tried Following.This will execute after executing fitBounds(). Need to execute before executing fitBounds()
var lineBounds = this._trail.getLineBounds()
, current_zoom = this.map.getZoom()
, center = this.map.getCenter();
this.map.fitBounds(lineBounds, {
padding: [29, 29],
});
this.map.once('zoomend', function() {
if (current_zoom > this.map.getZoom()) {
this.map.setView(center, current_zoom);
}
}.bind(this));
Upvotes: 0
Views: 201
Reputation: 28638
You'll have to set the minZoom
option your map instance. Problem is that you'll manually need to edit the options object of your map instance. The setMinZoom
and setMaxZoom
methods have been introduced in Leaflet v1.0.0-beta.2 and Mapbox isn't using that version yet. Otherwise you could simply do map.setMinZoom(number)
, now you'll have to resort to map.options.minZoom = number
. So after fitting your bounds, get the map's current zoomfactor using map.getZoom
method and set that factor value as your minZoom
option.
Upvotes: 1