Skip to content

Commit

Permalink
keep the map state on dataset page if the resource id is the same (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Feb 8, 2022
1 parent 9bd356b commit 37005c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions geonode_mapstore_client/client/js/epics/gnresource.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
setResourceThumbnail
} from '@js/api/geonode/v2';
import { configureMap } from '@mapstore/framework/actions/config';
import { mapSelector } from '@mapstore/framework/selectors/map';
import { getSelectedLayer } from '@mapstore/framework/selectors/layers';
import {
browseData,
Expand Down Expand Up @@ -85,7 +86,7 @@ import { getStyleProperties } from '@js/api/geonode/style';
const resourceTypes = {
[ResourceTypes.DATASET]: {
resourceObservable: (pk, options) => {
const { page, selectedLayer } = options || {};
const { page, selectedLayer, map: currentMap } = options || {};
return Observable.defer(() =>
axios.all([
getNewMapConfiguration(),
Expand Down Expand Up @@ -128,18 +129,19 @@ const resourceTypes = {
...mapConfig,
map: {
...mapConfig.map,
...currentMap, // keep configuration for other pages when resource id is the same (eg: center, zoom)
layers: [
...mapConfig.map.layers,
{
...selectedLayer, // keep configuration from other pages (eg: filters)
...selectedLayer, // keep configuration for other pages when resource id is the same (eg: filters)
...newLayer,
isDataset: true,
_v_: Date.now()
}
]
}
}),
...(extent
...((extent && !currentMap)
? [ setControlProperty('fitBounds', 'geometry', extent) ]
: []),
setControlProperty('toolbar', 'expanded', false),
Expand Down Expand Up @@ -404,7 +406,8 @@ export const gnViewerRequestResourceConfig = (action$, store) =>
styleService: styleServiceSelector(state),
isSamePreviousResource,
resourceData,
selectedLayer: isSamePreviousResource && getSelectedLayer(state)
selectedLayer: isSamePreviousResource && getSelectedLayer(state),
map: isSamePreviousResource && mapSelector(state)
}),
Observable.of(
...(pendingChanges?.resource ? [updateResourceProperties(pendingChanges.resource)] : []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,9 @@
"name": "QueryPanel",
"cfg": {
"activateQueryTool": true,
"toolsOptions": {
"hideCrossLayer": true
},
"spatialOperations": [
{
"id": "INTERSECTS",
Expand Down

0 comments on commit 37005c7

Please sign in to comment.