Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to show layers with Leaflet depending on scaling? For example not show counties until zoom level reaches 10.


share|improve this question
up vote 13 down vote accepted

yes you can set the scale in the constructor:

for example:

var layer = L.tileLayer("http://{s}{z}/{x}/{y}.jpg", {
        minZoom: 1,
        maxZoom: 14
    } ) ;

vectors don't have max/min properties, you could use a zoomend event to trigger adding or removing them, something like:

    map.on('zoomend ', function(e) {
         if ( map.getZoom() > 13 ){ map.removeLayer( vector )}
         else if ( map.getZoom() <= 13 ){ map.addLayer( vector )}
share|improve this answer
Thanks. Is this possible with L.polygon, not with L.tileLayer? It is, I just try it. Thanks so much! – againstflow Jan 15 '13 at 13:42
I have added a part about vectorlayers – warrieka Jan 15 '13 at 14:55
Thanks for the answer, it works which is awesome! Just wanted to add that the method is slightly different from warrieka mentioned. Needs to be - map.getZoom() not map.zoom map.on('zoomend ', function(e) { if ( map.getZoom() > 12 ){ map.removeLayer( vector )} else if ( map.getZoom() <= 12 ){ map.addLayer( vector )} }); – user22029 Sep 16 '13 at 8:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.