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
23 lines
702 B
JavaScript
23 lines
702 B
JavaScript
import { createContext, useContext } from 'react';
|
|
export const CONTEXT_VERSION = 1;
|
|
export function createLeafletContext(map) {
|
|
return Object.freeze({
|
|
__version: CONTEXT_VERSION,
|
|
map
|
|
});
|
|
}
|
|
export function extendContext(source, extra) {
|
|
return Object.freeze({
|
|
...source,
|
|
...extra
|
|
});
|
|
}
|
|
export const LeafletContext = createContext(null);
|
|
export const LeafletProvider = LeafletContext.Provider;
|
|
export function useLeafletContext() {
|
|
const context = useContext(LeafletContext);
|
|
if (context == null) {
|
|
throw new Error('No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>');
|
|
}
|
|
return context;
|
|
}
|