|
|
|
@ -1,13 +1,11 @@ |
|
|
|
|
import leaflet from 'leaflet'; |
|
|
|
|
import { Ref, useEffect } from 'preact/hooks'; |
|
|
|
|
|
|
|
|
|
import 'leaflet/dist/leaflet.css'; |
|
|
|
|
import { Coordinates } from '../../../shared/types'; |
|
|
|
|
import { type Ref, useEffect } from 'preact/hooks'; |
|
|
|
|
import type { Coordinates } from '../../../shared/types'; |
|
|
|
|
|
|
|
|
|
export const useMapClick = ( |
|
|
|
|
mapRef: Readonly<Ref<leaflet.Map | undefined>>, |
|
|
|
|
onMapClick: (leaflet: Coordinates) => void, |
|
|
|
|
) => { |
|
|
|
|
) => |
|
|
|
|
useEffect(() => { |
|
|
|
|
const map = mapRef.current; |
|
|
|
|
if (!map) { |
|
|
|
@ -23,4 +21,3 @@ export const useMapClick = ( |
|
|
|
|
map.removeEventListener('click', handler); |
|
|
|
|
}; |
|
|
|
|
}, [mapRef, onMapClick]); |
|
|
|
|
}; |
|
|
|
|