I want to add tooltips on a Leaflet map (without markers) and make them clickable. The following code adds a tooltip but it's not clickable:
var tooltip = L.tooltip({
direction: 'center',
permanent: true,
interactive: true,
noWrap: true,
opacity: 0.9
});
tooltip.setContent( "Example" );
tooltip.setLatLng(new L.LatLng(someLat, someLon));
tooltip.addTo(myLayer);
tooltip.on('click', function(event) {
console.log("Click!");
});
How can I make it work?
Easy solution: set the interactive
property to true:
tooltip interactive
in react-leaflet
<Tooltip interactive={true}><Tooltip />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With