bardu
bardu

Reputation: 737

Leaflet: set min/maxZoom dynamically

I'm using Leaflet v0.7 and there seem to be no setters for min/maxZoom on the map or tileLayer.

Is there any way to set these values dynamically?

Upvotes: 13

Views: 20705

Answers (2)

eightball
eightball

Reputation: 1230

Another way to do the same after map initialisation:

var map = L.map('map').setView([51.505, -0.09], 13);

map.setMinZoom(12);
map.setMaxZoom(14);

Upvotes: 1

yarl
yarl

Reputation: 3195

If you have your map initialized

var map = L.map('map').setView([51.505, -0.09], 13);

then you can simply do:

map.options.minZoom = 12;
map.options.maxZoom = 14;

Example JSFiddle.

Upvotes: 38

Related Questions