Download tmp-demo-frontend/node_modules/react-leaflet/lib/hooks.js from LarryD123/OurData: direct link, hf CLI and curl.
- Browser
- Download file 848 Bytes
-
https://huggingface.co/datasets/LarryD123/OurData/resolve/main/tmp-demo-frontend/node_modules/react-leaflet/lib/hooks.js
- Command line
-
hf download hf://datasets/LarryD123/OurData/tmp-demo-frontend/node_modules/react-leaflet/lib/hooks.js
-
curl -L -o hooks.js https://huggingface.co/datasets/LarryD123/OurData/resolve/main/tmp-demo-frontend/node_modules/react-leaflet/lib/hooks.js
848 Bytes
| import { useLeafletContext } from '@react-leaflet/core'; | |
| import { useEffect } from 'react'; | |
| export function useMap() { | |
| return useLeafletContext().map; | |
| } | |
| export function useMapEvent(type, handler) { | |
| const map = useMap(); | |
| useEffect(function addMapEventHandler() { | |
| // @ts-ignore event type | |
| map.on(type, handler); | |
| return function removeMapEventHandler() { | |
| // @ts-ignore event type | |
| map.off(type, handler); | |
| }; | |
| }, [ | |
| map, | |
| type, | |
| handler | |
| ]); | |
| return map; | |
| } | |
| export function useMapEvents(handlers) { | |
| const map = useMap(); | |
| useEffect(function addMapEventHandlers() { | |
| map.on(handlers); | |
| return function removeMapEventHandlers() { | |
| map.off(handlers); | |
| }; | |
| }, [ | |
| map, | |
| handlers | |
| ]); | |
| return map; | |
| } | |