@@ -806,6 +806,7 @@ export function MapView({
806806 bearing : number ;
807807 pitch : number ;
808808 } | null > ( null ) ;
809+ const editorDraftAnimationKeyRef = useRef ( "" ) ;
809810
810811 const stopUserLocation = useCallback ( ( ) => {
811812 if ( userLocationWatchIdRef . current !== null && navigator . geolocation ) {
@@ -2094,6 +2095,34 @@ export function MapView({
20942095 latitude : viewport . center . lat ,
20952096 zoom : viewport . zoom ,
20962097 } ;
2098+ useEffect ( ( ) => {
2099+ if ( ! isMapLoaded || mapEditor ?. kind !== "site" || ! mapEditorSiteDraft ) return ;
2100+ const animationKey = `${ mapEditor . resourceId ?? "new" } :${ mapEditorSiteDraft . lat . toFixed ( 6 ) } :${ mapEditorSiteDraft . lon . toFixed ( 6 ) } ` ;
2101+ if ( editorDraftAnimationKeyRef . current === animationKey ) return ;
2102+ editorDraftAnimationKeyRef . current = animationKey ;
2103+ setInteractionViewState ( null ) ;
2104+ const didAnimate = animateMapToCenter ( mapRef , {
2105+ center : { lat : mapEditorSiteDraft . lat , lon : mapEditorSiteDraft . lon } ,
2106+ zoom : viewport . zoom ,
2107+ padding : resolveMapCameraPadding ( fitChromePadding , fitBottomInset ) ,
2108+ duration : 420 ,
2109+ } ) ;
2110+ if ( ! didAnimate ) {
2111+ updateMapViewport ( {
2112+ center : { lat : mapEditorSiteDraft . lat , lon : mapEditorSiteDraft . lon } ,
2113+ zoom : viewport . zoom ,
2114+ } ) ;
2115+ }
2116+ } , [
2117+ fitBottomInset ,
2118+ fitChromePadding ,
2119+ isMapLoaded ,
2120+ mapEditor ?. kind ,
2121+ mapEditor ?. resourceId ,
2122+ mapEditorSiteDraft ,
2123+ updateMapViewport ,
2124+ viewport . zoom ,
2125+ ] ) ;
20972126 const mqttNodesInView = useMemo ( ( ) => {
20982127 const lonSpan = Math . max ( 0.12 , 360 / Math . pow ( 2 , activeViewState . zoom ) * 2.2 ) ;
20992128 const latSpan = Math . max ( 0.12 , 170 / Math . pow ( 2 , activeViewState . zoom ) * 1.8 ) ;
@@ -3424,9 +3453,17 @@ export function MapView({
34243453 </ Source >
34253454
34263455 { sites . map ( ( site ) => {
3427- const isSelected = ! armAddSiteOnNextEmptyMapClick && selectedSiteSet . has ( site . id ) ;
3456+ const isEditedSiteInSimulation =
3457+ mapEditor ?. kind === "site" &&
3458+ ! mapEditor . isNew &&
3459+ mapEditor . resourceId !== null &&
3460+ site . libraryEntryId === mapEditor . resourceId &&
3461+ mapEditorSiteDraft !== null ;
3462+ const isSelected = isEditedSiteInSimulation || ( ! armAddSiteOnNextEmptyMapClick && selectedSiteSet . has ( site . id ) ) ;
34283463 const pendingMove = pendingSiteMoves [ site . id ] ;
3429- const markerPosition = pendingMove ?. currentPosition ?? site . position ;
3464+ const markerPosition = isEditedSiteInSimulation
3465+ ? { lat : mapEditorSiteDraft . lat , lon : mapEditorSiteDraft . lon }
3466+ : pendingMove ?. currentPosition ?? site . position ;
34303467 const isTemporarilyMoved = Boolean ( pendingMove ) ;
34313468 const isPassFailMode = coverageVizMode === "passfail" && Boolean ( selectedFromSite ) ;
34323469 const isRelayMode = coverageVizMode === "relay" && Boolean ( selectedFromSite ) && Boolean ( selectedToSite ) ;
@@ -3445,8 +3482,8 @@ export function MapView({
34453482 longitude = { markerPosition . lon }
34463483 offset = { SITE_PIN_MARKER_OFFSET }
34473484 style = { { zIndex : markerZIndex } }
3448- onDrag = { ( event ) => onSiteDrag ( site . id , event ) }
3449- onDragEnd = { ( event ) => onSiteDragEnd ( site . id , event ) }
3485+ onDrag = { isEditedSiteInSimulation ? undefined : ( event ) => onSiteDrag ( site . id , event ) }
3486+ onDragEnd = { isEditedSiteInSimulation ? onEditorSiteDraftDragEnd : ( event ) => onSiteDragEnd ( site . id , event ) }
34503487 >
34513488 < MarkerActionButton
34523489 ariaLabel = { site . name }
@@ -3556,7 +3593,9 @@ export function MapView({
35563593 </ Marker >
35573594 ) : null }
35583595
3559- { mapEditor ?. kind === "site" && mapEditorSiteDraft ? (
3596+ { mapEditor ?. kind === "site" &&
3597+ mapEditorSiteDraft &&
3598+ ( mapEditor . isNew || ! sites . some ( ( site ) => site . libraryEntryId === mapEditor . resourceId ) ) ? (
35603599 < Marker
35613600 anchor = "bottom"
35623601 draggable = { canPersist }
0 commit comments