I would like to show icons if the user zooms to level 7 or more and hide the markers when zoom level is 6 or lower. I've tried using the 'zoomend' property in my function like so:
var shelter1 = L.marker([55.1, 11.6], {icon: shelterIcon}).addTo(map);
map.on('zoomend', function() {
var currentZoom = map.getZoom();
if(currentZoom >= 7) {
shelter1.bindPopup("Shelter");
}
else {
shelter1.hide();
}
});
I know that hide() is not valid. But I need something similar. Couldn't find anything in the Leaflet documentation.