mapbox / mapbox-gl-leaflet

binding from Mapbox GL JS to the Leaflet API
ISC License
522 stars 154 forks source link

Apply minZoom and maxZoom options to layer #142

Closed vcoppe closed 3 years ago

vcoppe commented 3 years ago

Currently, it is possible to zoom in infinitely on the maps even when maxZoom is specified. I have now included the zoom limits with an existing L.Layer function when the layer is added.

jgravois commented 3 years ago

it is possible to zoom in infinitely on the maps even when maxZoom is specified.

setting maxZoom on the map already works just fine.

var map = L.map('map', { maxZoom: 19 }).setView([38.9, -77], 15);
var gl = L.mapboxGL(/* */).addTo(map);

this change is to allow for setting the property on the mapboxGL layer, correct?

var gl = L.mapboxGL({ maxZoom: 19 }).addTo(map);

if so, in your application are you juggling multiple GL layers that you'd like to display with different maximum resolutions?

vcoppe commented 3 years ago

this change is to allow for setting the property on the mapboxGL layer, correct?

Yes indeed.

if so, in your application are you juggling multiple GL layers that you'd like to display with different maximum resolutions?

Yes, for example when using layers with 256 and 512 pixels tiles in the same map.

jgravois commented 3 years ago

sounds reasonable to me. thanks for the contribution!