I would like to implement a Tooltip attached to a Marker, then be able to drag that Tooltip anywhere on the map and draw a Polyline connecting the Tooltop to its parent marker. Is this possible? I can’t see any such behavior in the RL documentation.
How to make a draggable Tooltip in React-Leaflet v4?
225 Views Asked by RouteMapper At
2
There are 2 best solutions below
0
On
you can easily track your popup or tooltip using eventHandles and get event to element and use leaflet draggable function
<Popup
// permanent
className="bg-white "
direction="bottom"
// offset={[-3, -2]}
ref={markerDiv}
interactive={true}
eventHandlers={{
mouseover: (e) => {
// console.log('over',e.target.getElement())
const element = e.target.getElement();
const draggable = new L.Draggable(element)
draggable.enable()
}
}}
>
Your text here
</Popup>
first you need to get your popup or tooltip element when its created using useRef and after set popup or tooltip you must get elelemt using userRef.current.getElement() after this you will get the div element and use leaflet Dragrable function and enable it you must try to you own testing area you will understood very well