DieselDepot-APP/node_modules/@react-leaflet/core/lib/control.js
SJCoetz 34608475cb feat: add depot map integration
Add Leaflet and react-leaflet dependencies for interactive map functionality
Extend DDDepot type with optional latitude/longitude fields for map markers
Update site metadata and admin settings page text
Add client-side DepotMap component to render depot locations
Update PocketBase admin token in environment configuration
2026-07-20 12:31:18 +02:00

30 lines
1,008 B
JavaScript

import { useEffect, useRef } from 'react';
import { useLeafletContext } from './context.js';
export function createControlHook(useElement) {
return function useLeafletControl(props) {
const context = useLeafletContext();
const elementRef = useElement(props, context);
const { instance } = elementRef.current;
const positionRef = useRef(props.position);
const { position } = props;
useEffect(function addControl() {
instance.addTo(context.map);
return function removeControl() {
instance.remove();
};
}, [
context.map,
instance
]);
useEffect(function updateControl() {
if (position != null && position !== positionRef.current) {
instance.setPosition(position);
positionRef.current = position;
}
}, [
instance,
position
]);
return elementRef;
};
}