Download tmp-demo-frontend/node_modules/react-leaflet/lib/SVGOverlay.js from LarryD123/OurData: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/LarryD123/OurData/resolve/main/tmp-demo-frontend/node_modules/react-leaflet/lib/SVGOverlay.js
- Command line
-
hf download hf://datasets/LarryD123/OurData/tmp-demo-frontend/node_modules/react-leaflet/lib/SVGOverlay.js
-
curl -L -o SVGOverlay.js https://huggingface.co/datasets/LarryD123/OurData/resolve/main/tmp-demo-frontend/node_modules/react-leaflet/lib/SVGOverlay.js
1.33 kB
| import { createElementHook, createElementObject, createLayerHook, updateMediaOverlay } from '@react-leaflet/core'; | |
| import { SVGOverlay as LeafletSVGOverlay } from 'leaflet'; | |
| import { forwardRef, useImperativeHandle } from 'react'; | |
| import { createPortal } from 'react-dom'; | |
| export const useSVGOverlayElement = createElementHook(function createSVGOverlay(props, context) { | |
| const { attributes, bounds, ...options } = props; | |
| const container = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); | |
| container.setAttribute('xmlns', 'http://www.w3.org/2000/svg'); | |
| if (attributes != null) { | |
| for (const name of Object.keys(attributes)){ | |
| container.setAttribute(name, attributes[name]); | |
| } | |
| } | |
| const overlay = new LeafletSVGOverlay(container, bounds, options); | |
| return createElementObject(overlay, context, container); | |
| }, updateMediaOverlay); | |
| export const useSVGOverlay = createLayerHook(useSVGOverlayElement); | |
| function SVGOverlayComponent({ children, ...options }, forwardedRef) { | |
| const { instance, container } = useSVGOverlay(options).current; | |
| useImperativeHandle(forwardedRef, ()=>instance); | |
| return container == null || children == null ? null : /*#__PURE__*/ createPortal(children, container); | |
| } | |
| export const SVGOverlay = /*#__PURE__*/ forwardRef(SVGOverlayComponent); | |