✨ 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
69 lines
2.3 KiB
JavaScript
69 lines
2.3 KiB
JavaScript
import { useState, useEffect } from 'react';
|
|
import { useConstant } from '../../utils/use-constant.mjs';
|
|
import { getOrigin, checkTargetForNewValues } from '../../render/utils/setters.mjs';
|
|
import { makeUseVisualState } from '../../motion/utils/use-visual-state.mjs';
|
|
import { createBox } from '../../projection/geometry/models.mjs';
|
|
import { VisualElement } from '../../render/VisualElement.mjs';
|
|
import { animateVisualElement } from '../interfaces/visual-element.mjs';
|
|
|
|
const createObject = () => ({});
|
|
class StateVisualElement extends VisualElement {
|
|
build() { }
|
|
measureInstanceViewportBox() {
|
|
return createBox();
|
|
}
|
|
resetTransform() { }
|
|
restoreTransform() { }
|
|
removeValueFromRenderState() { }
|
|
renderInstance() { }
|
|
scrapeMotionValuesFromProps() {
|
|
return createObject();
|
|
}
|
|
getBaseTargetFromProps() {
|
|
return undefined;
|
|
}
|
|
readValueFromInstance(_state, key, options) {
|
|
return options.initialState[key] || 0;
|
|
}
|
|
sortInstanceNodePosition() {
|
|
return 0;
|
|
}
|
|
makeTargetAnimatableFromInstance({ transition, transitionEnd, ...target }) {
|
|
const origin = getOrigin(target, transition || {}, this);
|
|
checkTargetForNewValues(this, target, origin);
|
|
return { transition, transitionEnd, ...target };
|
|
}
|
|
}
|
|
const useVisualState = makeUseVisualState({
|
|
scrapeMotionValuesFromProps: createObject,
|
|
createRenderState: createObject,
|
|
});
|
|
/**
|
|
* This is not an officially supported API and may be removed
|
|
* on any version.
|
|
*/
|
|
function useAnimatedState(initialState) {
|
|
const [animationState, setAnimationState] = useState(initialState);
|
|
const visualState = useVisualState({}, false);
|
|
const element = useConstant(() => {
|
|
return new StateVisualElement({ props: {}, visualState, presenceContext: null }, { initialState });
|
|
});
|
|
useEffect(() => {
|
|
element.mount({});
|
|
return () => element.unmount();
|
|
}, [element]);
|
|
useEffect(() => {
|
|
element.update({
|
|
onUpdate: (v) => {
|
|
setAnimationState({ ...v });
|
|
},
|
|
}, null);
|
|
}, [setAnimationState, element]);
|
|
const startAnimation = useConstant(() => (animationDefinition) => {
|
|
return animateVisualElement(element, animationDefinition);
|
|
});
|
|
return [animationState, startAnimation];
|
|
}
|
|
|
|
export { useAnimatedState };
|