I'd like to use, say, a circle or map pin when zoomed out, and for this to change to a polygon / shapefile when zoomed in (specifying the zoom level at which the change occurs).

Can Leaflet do this?


1 Answer 1


This should get you started, might need some adaption to your usecase:

map.on('zoomend', function() {                        //triggers after zoom event
        if (map.getZoom() <x){                        //where x is the zoom level where the change occurs
        else {
  • 2
    In a (very small) nutshell, this is correct. You'll need to subscribe to Leaflet's map state change events, evaluate the new map state's current zoom level, then make modifications to the target layer.
    – elrobis
    Jul 9, 2020 at 21:26
  • Thank you. Is there also a way to do this with Folium?
    – zadrozny
    Jul 9, 2020 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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