Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

How to set up a maximal zoom for some layer, for example state polygons? I need that my US polygons which represent states have maxZoom 6, and when zoomed higher than 6, that US counties show up instead of states. Is that possible in Leaflet? All states are defined like Leaflet polygons.

Thanks in advance.

share|improve this question

It sounds like you want to toggle the state info off and turn on counties when zoomed in to a certain zoom level. This should be simple all you need to do is listen to the zoomend event then toggle the layers based on the zoom level. Here is some pseudo code.

map.on('zoomend', function(e){
    var zoomLevel = map.getZoom();
    if(zoomLevel == 6){
       //then toggle vibility or add/remove the desired layers
    }
    else{
       //Do the opposite
    }
});
share|improve this answer

Your Answer

 
discard

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.