danzel / Leaflet.utfgrid

A UTFGrid implementation for leaflet that is super small.
MIT License
132 stars 51 forks source link

Layer is not added after zooming into min/max zoom range #52

Open svancise opened 8 years ago

svancise commented 8 years ago

Hi,

I noticed something when working with a large layer that only is displayed on zoom levels 15-18. If the layer is added at a zoom above the minzoom, say 16, and you zoom into the layers range, 15, the layer does not request the necessary grid tiles. The layer has been added, its just not requesting data.

I took a look at the src and it looks like the zoom is compared to min/max zoom in the onAdd event. However, it returns before the move events are applied. Meaning if a layer is added while zoomed out, then you'll never actually be able to fire the moveend event that updates the layer.

Is this check necessary for anything else? Removing that check does not seem to cause any issues and resolves my problem but I want to make sure there are no unintended consequences.

Thanks, Spencer