From 72de91bb2ef77b6e428b98d79b0e8e4a5def7eba Mon Sep 17 00:00:00 2001 From: Dave Falke Date: Thu, 26 Oct 2023 14:33:11 -0400 Subject: [PATCH 1/4] Use recenteredMarkers --- .../libs/components/src/map/SemanticMarkers.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/libs/components/src/map/SemanticMarkers.tsx b/packages/libs/components/src/map/SemanticMarkers.tsx index 81c8140699..9d4165b35c 100644 --- a/packages/libs/components/src/map/SemanticMarkers.tsx +++ b/packages/libs/components/src/map/SemanticMarkers.tsx @@ -120,28 +120,34 @@ export default function SemanticMarkers({ markers: recenteredMarkers, }); setConsolidatedMarkers(animationValues.markers); - timeoutVariable = enqueueZoom(animationValues.zoomType); + timeoutVariable = enqueueZoom( + animationValues.zoomType, + recenteredMarkers + ); } else { /** First render of markers **/ - setConsolidatedMarkers(markers); + setConsolidatedMarkers(recenteredMarkers); } // Update previous markers with the original markers array setPrevMarkers(markers); } - function enqueueZoom(zoomType: string | null) { + function enqueueZoom( + zoomType: string | null, + nextMarkers: ReactElement[] + ) { /** If we are zooming in then reset the marker elements. When initially rendered * the new markers will start at the matching existing marker's location and here we will * reset marker elements so they will animated to their final position **/ if (zoomType === 'in') { - setConsolidatedMarkers(markers); + setConsolidatedMarkers(nextMarkers); } else if (zoomType === 'out') { /** If we are zooming out then remove the old markers after they finish animating. **/ return window.setTimeout( () => { - setConsolidatedMarkers(markers); + setConsolidatedMarkers(nextMarkers); }, animation ? animation.duration : 0 ); From 7f7d60f7f2d3fb9832829923c6155db1a224e5c0 Mon Sep 17 00:00:00 2001 From: Bob Date: Fri, 27 Oct 2023 23:24:48 +0100 Subject: [PATCH 2/4] suggested fix for donutmarker only so far --- packages/libs/components/src/map/SemanticMarkers.tsx | 3 ++- .../lib/map/analysis/mapTypes/plugins/DonutMarkerMapType.tsx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/libs/components/src/map/SemanticMarkers.tsx b/packages/libs/components/src/map/SemanticMarkers.tsx index 9d4165b35c..e120a754da 100644 --- a/packages/libs/components/src/map/SemanticMarkers.tsx +++ b/packages/libs/components/src/map/SemanticMarkers.tsx @@ -163,7 +163,8 @@ export default function SemanticMarkers({ [consolidatedMarkers] ); - useFlyToMarkers({ markers: refinedMarkers, flyToMarkers, flyToMarkersDelay }); + // this should use the unadulterated markers (which are always in the "main world") + useFlyToMarkers({ markers, flyToMarkers, flyToMarkersDelay }); return <>{refinedMarkers}; } diff --git a/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/DonutMarkerMapType.tsx b/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/DonutMarkerMapType.tsx index 9fae72f96e..e3a5cfb95a 100644 --- a/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/DonutMarkerMapType.tsx +++ b/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/DonutMarkerMapType.tsx @@ -318,7 +318,7 @@ function MapLayerComponent(props: MapTypeMapLayerProps) { !markerDataResponse.isFetching && isApproxSameViewport(props.appState.viewport, defaultViewport) } - flyToMarkersDelay={500} + flyToMarkersDelay={2000} /> )} @@ -438,6 +438,7 @@ function useMarkerData(props: DistributionMarkerDataProps) { data: markerData, error, isFetching, + isPreviousData, } = useDistributionMarkerData(props); if (markerData == null) return { error, isFetching }; @@ -472,7 +473,7 @@ function useMarkerData(props: DistributionMarkerDataProps) { return { error, - isFetching, + isFetching: isFetching || isPreviousData, markerProps, totalVisibleWithOverlayEntityCount, totalVisibleEntityCount, From c7f2c44acc4d547873d22faa56a5bb697996c645 Mon Sep 17 00:00:00 2001 From: Bob MacCallum Date: Mon, 6 Nov 2023 12:42:06 +0000 Subject: [PATCH 3/4] fix animation in other worlds bug --- packages/libs/components/src/map/SemanticMarkers.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/libs/components/src/map/SemanticMarkers.tsx b/packages/libs/components/src/map/SemanticMarkers.tsx index e120a754da..22726453df 100644 --- a/packages/libs/components/src/map/SemanticMarkers.tsx +++ b/packages/libs/components/src/map/SemanticMarkers.tsx @@ -109,12 +109,7 @@ export default function SemanticMarkers({ // but don't animate if we moved markers by 360 deg. longitude // because the DriftMarker or Leaflet.Marker.SlideTo code seems to // send everything back to the 'main' world. - if ( - recenteredMarkers.length > 0 && - prevMarkers.length > 0 && - animation && - !didRecenterMarkers - ) { + if (recenteredMarkers.length > 0 && prevMarkers.length > 0 && animation) { const animationValues = animation.animationFunction({ prevMarkers, markers: recenteredMarkers, @@ -129,8 +124,8 @@ export default function SemanticMarkers({ setConsolidatedMarkers(recenteredMarkers); } - // Update previous markers with the original markers array - setPrevMarkers(markers); + // Update previous markers + setPrevMarkers(recenteredMarkers); } function enqueueZoom( From df4a0ba331ee5d93884137df0829a76836e52383 Mon Sep 17 00:00:00 2001 From: Bob MacCallum Date: Mon, 6 Nov 2023 13:18:17 +0000 Subject: [PATCH 4/4] fixed up bar plot and bubble markers but needs more testing --- .../lib/map/analysis/mapTypes/plugins/BarMarkerMapType.tsx | 5 +++-- .../map/analysis/mapTypes/plugins/BubbleMarkerMapType.tsx | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BarMarkerMapType.tsx b/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BarMarkerMapType.tsx index 1c3d52cd76..840c6b4c15 100644 --- a/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BarMarkerMapType.tsx +++ b/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BarMarkerMapType.tsx @@ -359,7 +359,7 @@ function MapLayerComponent(props: MapTypeMapLayerProps) { !markerData.isFetching && isApproxSameViewport(props.appState.viewport, defaultViewport) } - flyToMarkersDelay={500} + flyToMarkersDelay={2000} /> )} @@ -597,6 +597,7 @@ function useMarkerData(props: MarkerDataProps) { data: markerData, error, isFetching, + isPreviousData, } = useDistributionMarkerData(props); if (markerData == null) return { error, isFetching }; @@ -648,7 +649,7 @@ function useMarkerData(props: MarkerDataProps) { return { error, - isFetching, + isFetching: isFetching || isPreviousData, markerProps, totalVisibleWithOverlayEntityCount, totalVisibleEntityCount, diff --git a/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BubbleMarkerMapType.tsx b/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BubbleMarkerMapType.tsx index f4c0f52bb0..ef5c3694fd 100644 --- a/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BubbleMarkerMapType.tsx +++ b/packages/libs/eda/src/lib/map/analysis/mapTypes/plugins/BubbleMarkerMapType.tsx @@ -201,10 +201,10 @@ function BubbleMapLayer(props: MapTypeMapLayerProps) { markers={markers} animation={defaultAnimation} flyToMarkers={ - !markersData.isFetching && + !(markersData.isFetching || markersData.isPreviousData) && isApproxSameViewport(props.appState.viewport, defaultViewport) } - flyToMarkersDelay={500} + flyToMarkersDelay={2000} /> )}