Skip to content

Commit

Permalink
#1573: Fix - Map save doesn't preserve zoom when created from a datas…
Browse files Browse the repository at this point in the history
…et (#1580)
  • Loading branch information
dsuren1 authored Oct 18, 2023
1 parent 1b272aa commit 293c46e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions geonode_mapstore_client/client/js/epics/gnresource.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ import {
import {
setControlProperty,
resetControls,
SET_CONTROL_PROPERTY
SET_CONTROL_PROPERTY,
setControlProperties
} from '@mapstore/framework/actions/controls';
import {
resourceToLayerConfig,
Expand Down Expand Up @@ -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)
);
Expand Down
6 changes: 4 additions & 2 deletions geonode_mapstore_client/client/js/plugins/FitBounds.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ function FitBoundsPlugin({ mapProjection, ...props }) {
return geometry;
}
const geometry = useMemo(() => validateGeometry(props.geometry, mapProjection), [props.geometry, mapProjection]);
return <FitBounds active { ...props } geometry={geometry}/>;
return <FitBounds active { ...props } duration={props.duration} geometry={geometry}/>;
}

const ConnectedFitBoundsPlugin = connect(
createSelector([
state => state?.controls?.fitBounds?.geometry,
state => state?.controls?.fitBounds?.duration,
projectionSelector
], (geometry, mapProjection) => ({
], (geometry, duration, mapProjection) => ({
geometry,
duration,
mapProjection
}))
)(FitBoundsPlugin);
Expand Down

0 comments on commit 293c46e

Please sign in to comment.