Geographic Information Systems Asked on October 6, 2021
My objective is to plot polygons and assign a tooltip label to each one. For some reason, my code doesn’t seems to work.
poly_geojson = L.geoJson(poly_gon,{
onEachFeature(feature, layer) {
if (feature.properties.sourceLang == "en") {
layer.bindTooltip("<h4>"+feature.properties.name+"</h4>")
}
else {
layer.bindTooltip("<h4>"+feature.properties.name+"</h4>")
}
}
}).addTo(map);
According to leaflet's documentation - after
Code - I added the 'options fix' from the comments:bindTooltip()
- add openTooltip()
poly_geojson = L.geoJson(poly_gon,{
onEachFeature : function(feature, layer) {
if (feature.properties.sourceLang == "en") {
layer.bindTooltip("<h4>"+feature.properties.name+"</h4>");
}
else {
layer.bindTooltip("<h4>"+feature.properties.name+"</h4>");
}
}
}).addTo(map);
EDIT: no need to use openTooltip() please check this codepen
Answered by NettaB on October 6, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP