1

In there a way to disable onEachFeature at zoom level? I have a GeoJSON object with highlightFeature and resetHighlight functions. I want to disable resetHighlight at zoom level 8

    var rejon_3;
    function resetHighlight3(e) {
        rejon_3.resetStyle(e.target);
        info.update();
    }

    function onEachFeature33(feature, layer) {
        layer.on({
            mouseover: highlightFeature
        });
    }

    function x3(e) {map.fitBounds(e.target.getBounds())}

    function onEachFeature3(feature, layer) {
        layer.on({
            mouseover: highlightFeature,
            mouseout: resetHighlight3,
            click: x3
        });
    }


    rejon_3 = L.geoJson(exp_3, {
        style: style3,
        onEachFeature: onEachFeature3
    }).addTo(map);

    feature_group.addLayer(rejon_3);
1

In there a way to disable onEachFeature at zoom level?

No.

onEachFeature iterates through the features, regardless of zoom level. Even if the L.FeatureGroup they belong is never displayed. You're mixing concepts here.

I want to disable resetHighlight at zoom level 8

Then make your resetHighlight event handler do nothing under certain conditions:

function resetHighlight(ev) {
  if (map.getZoom() > 8) {
    doSomething();
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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