I am using Leaflet 1.7.1.
I want to add simple tooltips to poly-layer after they are constructed. I tried everything. External onEachFeature()
function featureGroup
. But it seems that events the layers are not triggered. With the legacy Version, it is functioning. Here is the code. Styles are applied and the onEachFeature()
function is executed.
Where is my problem?
plz.postcodes = L.geoJSON(data, {
style: function (feature) {
return {
color: 'yellow',
fillColor: 'black',
weight: 1,
opacity: 1,
fillOpacity: 0.1
};
},
onEachFeature: function(feature,layer) {
console.log(feature.properties.plz);
layer.on({
mouseover: function (e) {
console.log(e.target);
},
mouseout: function () {
plz.map.closeTooltip();
},
});
}
}).addTo(plz.map);