T.Horbinski T.Horbinski - 21 days ago 11
Javascript Question

Leaflet Zoom Map Layer

I am looking function which enable me to loss of parts of Layer when zooming the map.

map.on('zoomend', onZoomend)
function onZoomend(feature){
if(map.getZoom()<11)
{map.addLayer("road_2"==feature.properties.density)};

if(map.getZoom()>11)
{map.removeLayer("road_2"==feature.properties.density)};
}

Answer

I am not sure if I understand you right, but you want to remove a layer when zooming in and adding it when zooming out?

You just can use:
if(map.getZoom()<11){
    mylayer.removeFrom(map);
}else{    
    mylayer.addTo(map);
}

Did I understand you right?