✨ MAJOR FEATURES: • Auto-zoom intelligence với smart bounds fitting • Enhanced 3D GPS markers với pulsing effects • Professional route display với 6-layer rendering • Status-based parking icons với availability indicators • Production-ready build optimizations 🗺️ AUTO-ZOOM FEATURES: • Smart bounds fitting cho GPS + selected parking • Adaptive padding (50px) cho visual balance • Max zoom control (level 16) để tránh quá gần • Dynamic centering khi không có selection 🎨 ENHANCED VISUALS: • 3D GPS marker với multi-layer pulse effects • Advanced parking icons với status colors • Selection highlighting với animation • Dimming system cho non-selected items 🛣️ ROUTE SYSTEM: • OpenRouteService API integration • Multi-layer route rendering (glow, shadow, main, animated) • Real-time distance & duration calculation • Visual route info trong popup 📱 PRODUCTION READY: • SSR safe với dynamic imports • Build errors resolved • Global deployment via Vercel • Optimized performance 🌍 DEPLOYMENT: • Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app • Bundle size: 22.8 kB optimized • Global CDN distribution • HTTPS enabled 💾 VERSION CONTROL: • MapView-v2.0.tsx backup created • MAPVIEW_VERSIONS.md documentation • Full version history tracking
73 lines
2.7 KiB
JavaScript
73 lines
2.7 KiB
JavaScript
import { LeafletProvider, addClassName, useLeafletContext } from '@react-leaflet/core';
|
|
import React, { forwardRef, useState, useEffect, useImperativeHandle, useMemo } from 'react';
|
|
import { createPortal } from 'react-dom';
|
|
const DEFAULT_PANES = [
|
|
'mapPane',
|
|
'markerPane',
|
|
'overlayPane',
|
|
'popupPane',
|
|
'shadowPane',
|
|
'tilePane',
|
|
'tooltipPane'
|
|
];
|
|
function omitPane(obj, pane) {
|
|
const { [pane]: _p , ...others } = obj;
|
|
return others;
|
|
}
|
|
function createPane(name, props, context) {
|
|
if (DEFAULT_PANES.indexOf(name) !== -1) {
|
|
throw new Error(`You must use a unique name for a pane that is not a default Leaflet pane: ${name}`);
|
|
}
|
|
if (context.map.getPane(name) != null) {
|
|
throw new Error(`A pane with this name already exists: ${name}`);
|
|
}
|
|
const parentPaneName = props.pane ?? context.pane;
|
|
const parentPane = parentPaneName ? context.map.getPane(parentPaneName) : undefined;
|
|
const element = context.map.createPane(name, parentPane);
|
|
if (props.className != null) {
|
|
addClassName(element, props.className);
|
|
}
|
|
if (props.style != null) {
|
|
Object.keys(props.style).forEach((key)=>{
|
|
// @ts-ignore
|
|
element.style[key] = props.style[key];
|
|
});
|
|
}
|
|
return element;
|
|
}
|
|
function PaneComponent(props, forwardedRef) {
|
|
const [paneName] = useState(props.name);
|
|
const [paneElement, setPaneElement] = useState(null);
|
|
useImperativeHandle(forwardedRef, ()=>paneElement, [
|
|
paneElement
|
|
]);
|
|
const context = useLeafletContext();
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
const newContext = useMemo(()=>({
|
|
...context,
|
|
pane: paneName
|
|
}), [
|
|
context
|
|
]);
|
|
useEffect(()=>{
|
|
setPaneElement(createPane(paneName, props, context));
|
|
return function removeCreatedPane() {
|
|
const pane = context.map.getPane(paneName);
|
|
pane?.remove?.();
|
|
// @ts-ignore map internals
|
|
if (context.map._panes != null) {
|
|
// @ts-ignore map internals
|
|
context.map._panes = omitPane(context.map._panes, paneName);
|
|
// @ts-ignore map internals
|
|
context.map._paneRenderers = omitPane(// @ts-ignore map internals
|
|
context.map._paneRenderers, paneName);
|
|
}
|
|
};
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, []);
|
|
return props.children != null && paneElement != null ? /*#__PURE__*/ createPortal(/*#__PURE__*/ React.createElement(LeafletProvider, {
|
|
value: newContext
|
|
}, props.children), paneElement) : null;
|
|
}
|
|
export const Pane = /*#__PURE__*/ forwardRef(PaneComponent);
|