I have a leaflet map that zooms and fits on the bounds of the polygon that is clicked via onEachFeature.
Is there a way to disable this at a certain zoom level? I add new layers on the 'zoomend' event, I just can't figure out if disabling on 'click' function is possible.
function onEachFeature(feature, layer) { layer.on('mouseover', function() { this.setStyle({ 'fillColor': 'gray' }); }); layer.on('mouseout', function() { this.setStyle({ 'fillColor': '#fff' }); }); layer.on('click', function() { map.fitBounds(layer.getBounds()) }); }var json_countiesJSON = new L.geoJson(json_counties, { style: doStylecounties, onEachFeature: onEachFeature }).addTo(map)map.on('zoomend ', function(e) { if (map.getZoom() < 10) { map.removeLayer(clusterWells) json_countiesJSON.setStyle({ 'fillOpacity': '0.7' }); } else if (map.getZoom() >= 10) { map.addLayer(clusterWells); json_countiesJSON.setStyle({ 'fillOpacity': '0.0' }); } });
أكثر...
Is there a way to disable this at a certain zoom level? I add new layers on the 'zoomend' event, I just can't figure out if disabling on 'click' function is possible.
function onEachFeature(feature, layer) { layer.on('mouseover', function() { this.setStyle({ 'fillColor': 'gray' }); }); layer.on('mouseout', function() { this.setStyle({ 'fillColor': '#fff' }); }); layer.on('click', function() { map.fitBounds(layer.getBounds()) }); }var json_countiesJSON = new L.geoJson(json_counties, { style: doStylecounties, onEachFeature: onEachFeature }).addTo(map)map.on('zoomend ', function(e) { if (map.getZoom() < 10) { map.removeLayer(clusterWells) json_countiesJSON.setStyle({ 'fillOpacity': '0.7' }); } else if (map.getZoom() >= 10) { map.addLayer(clusterWells); json_countiesJSON.setStyle({ 'fillOpacity': '0.0' }); } });
أكثر...