From 293c46ea11e7e531776cbd5299f1469c486fb0ca Mon Sep 17 00:00:00 2001 From: Suren Date: Wed, 18 Oct 2023 12:41:22 +0530 Subject: [PATCH] #1573: Fix - Map save doesn't preserve zoom when created from a dataset (#1580) --- geonode_mapstore_client/client/js/epics/gnresource.js | 6 ++++-- geonode_mapstore_client/client/js/plugins/FitBounds.jsx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/geonode_mapstore_client/client/js/epics/gnresource.js b/geonode_mapstore_client/client/js/epics/gnresource.js index 671a0f0255..4e54b51904 100644 --- a/geonode_mapstore_client/client/js/epics/gnresource.js +++ b/geonode_mapstore_client/client/js/epics/gnresource.js @@ -62,7 +62,8 @@ import { import { setControlProperty, resetControls, - SET_CONTROL_PROPERTY + SET_CONTROL_PROPERTY, + setControlProperties } from '@mapstore/framework/actions/controls'; import { resourceToLayerConfig, @@ -219,7 +220,8 @@ const resourceTypes = { } : mapConfig), ...(extent - ? [ setControlProperty('fitBounds', 'geometry', extent) ] + // Add duration to allow map config to be properly updated with zoom on fitBounds action + ? [ setControlProperties('fitBounds', 'geometry', extent, "duration", 400) ] : []), setControlProperty('toolbar', 'expanded', false) ); diff --git a/geonode_mapstore_client/client/js/plugins/FitBounds.jsx b/geonode_mapstore_client/client/js/plugins/FitBounds.jsx index 48ec9ab1de..9e1725a09c 100644 --- a/geonode_mapstore_client/client/js/plugins/FitBounds.jsx +++ b/geonode_mapstore_client/client/js/plugins/FitBounds.jsx @@ -30,15 +30,17 @@ function FitBoundsPlugin({ mapProjection, ...props }) { return geometry; } const geometry = useMemo(() => validateGeometry(props.geometry, mapProjection), [props.geometry, mapProjection]); - return ; + return ; } const ConnectedFitBoundsPlugin = connect( createSelector([ state => state?.controls?.fitBounds?.geometry, + state => state?.controls?.fitBounds?.duration, projectionSelector - ], (geometry, mapProjection) => ({ + ], (geometry, duration, mapProjection) => ({ geometry, + duration, mapProjection })) )(FitBoundsPlugin);