diff --git a/packages/react-leaflet/src/Tooltip.tsx b/packages/react-leaflet/src/Tooltip.tsx index b26e3e9b..09d98d57 100644 --- a/packages/react-leaflet/src/Tooltip.tsx +++ b/packages/react-leaflet/src/Tooltip.tsx @@ -33,7 +33,7 @@ export const Tooltip = createOverlayComponent( props: TooltipProps, setOpen: SetOpenFunc, ) { - const { onClose, onOpen } = props + const { onClose, onOpen, position } = props useEffect( function addTooltip() { @@ -46,6 +46,10 @@ export const Tooltip = createOverlayComponent( const onTooltipOpen = (event: TooltipEvent) => { if (event.tooltip === instance) { + if (position) { + instance.setLatLng(position) + } + instance.update() setOpen(true) onOpen?.() @@ -76,7 +80,7 @@ export const Tooltip = createOverlayComponent( } } }, - [element, context, setOpen, onClose, onOpen], + [element, context, setOpen, onClose, onOpen, position], ) }, )