I am trying to put permanent tooltip on the center of polygons on a leaflet map but they still are far from the polygon… Even if I change offset.
My code (in onEachFeature function) is :
layer.bindTooltip(
feature.properties.label,
{
permanent: true,
direction: 'left',
offset: L.point({x: 100, y: 0}),
//className: 'labelIlot',
opacity: 0.7
}
).openTooltip();
I get :
the tooltips are very far from the polygon…
I tried to find the coord of the center of the polygon (getBounds().getCenter()) and to put a marker. it works
but.. when I put the tooltip on the marker, it is still far from the marker… why ?
And sometimes, I have multipolygons…. I would like a tooltip by part of polygon…
I tried the plugin https://github.com/ZijingPeng/leaflet-tooltip-layout?tab=readme-ov-file but it didn’t works…
Thank’s.