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);