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) {
                        mouseover: function (e) {
                        mouseout: function () {
  • Found the solution. I forgot to change the CSS from the old legacy version to the new version. It seems that tooltip and popups are invisible with the CSS. Commented Nov 16, 2021 at 10:08

1 Answer 1


All layers in Leaflet have .bindTooltip method (see Tooltip methods section in https://leafletjs.com/reference-1.7.1.html#layer). It takes care of opening tooltip on mouseover and closing it on mouseout.

If your desired tooltip content is feature.properties.plz, then relevant part of the code would look something like this:

onEachFeature: function(feature, layer) {
  • Thank you ... I already tried this. It seems to me that the svg in the overlay pane is visible but events are not triggered. I already tried to change the z-index. Commented Oct 25, 2021 at 9:19
  • Any errors in the browser debugger console?
    – TomazicM
    Commented Oct 25, 2021 at 9:23
  • And what do you mean by "svg in the overlay pane is visible"? That GeoJSON features are visible?
    – TomazicM
    Commented Oct 25, 2021 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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