Skip to content

Commit

Permalink
[Fixes #334][Backport 3.3.x] Implement support for MapStore annotatio…
Browse files Browse the repository at this point in the history
…ns (#374)
  • Loading branch information
allyoucanmap authored Jul 27, 2021
1 parent 34d72af commit 5eeb9d4
Show file tree
Hide file tree
Showing 24 changed files with 975 additions and 108 deletions.
222 changes: 116 additions & 106 deletions geonode_mapstore_client/client/js/apps/gn-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import mapPopups from '@mapstore/framework/reducers/mapPopups';
import catalog from '@mapstore/framework/reducers/catalog';
import searchconfig from '@mapstore/framework/reducers/searchconfig';
import widgets from '@mapstore/framework/reducers/widgets';
import annotations from '@mapstore/framework/reducers/annotations';
// end

import MapView from '@js/routes/MapView';
Expand Down Expand Up @@ -88,113 +89,122 @@ const routes = [

initializeApp();

document.addEventListener('DOMContentLoaded', function() {
Promise.all([
getConfiguration(),
getAccountInfo()
])
.then(([localConfig, user]) => {
const {
securityState,
geoNodeConfiguration,
pluginsConfigKey,
geoNodePageConfig,
query,
configEpics,
mapType = 'openlayers',
permissions,
onStoreInit,
targetId = 'ms-container',
settings
} = setupConfiguration({
localConfig,
user
});

Promise.all([
getConfiguration(),
getAccountInfo()
])
.then(([localConfig, user]) => {
const {
securityState,
geoNodeConfiguration,
pluginsConfigKey,
geoNodePageConfig,
query,
configEpics,
mapType = 'openlayers',
permissions,
onStoreInit,
targetId = 'ms-container',
settings
} = setupConfiguration({
localConfig,
user
});

// get the correct map layout
const mapLayout = getConfigProp('mapLayout') || {};
setConfigProp('mapLayout', mapLayout[query.theme] || mapLayout.viewer);

// register custom arcgis layer
import('@js/components/' + mapType + '/ArcGisMapServer')
.then(() => {
main({
targetId,
enableExtensions: true,
appComponent: withRoutes(routes)(ConnectedRouter),
loaderComponent: MainLoader,
initialState: {
defaultState: {
...securityState,
maptype: {
mapType
// get the correct map layout
const mapLayout = getConfigProp('mapLayout') || {};
setConfigProp('mapLayout', mapLayout[query.theme] || mapLayout.viewer);

// register custom arcgis layer
import('@js/components/' + mapType + '/ArcGisMapServer')
.then(() => {
main({
targetId,
enableExtensions: true,
appComponent: withRoutes(routes)(ConnectedRouter),
loaderComponent: MainLoader,
initialState: {
defaultState: {
...securityState,
maptype: {
mapType
},
annotations: {
config: {
multiGeometry: true,
validationErrors: {}
},
defaultTextAnnotation: 'New'
}
}
}
},
themeCfg: {
path: '/static/mapstore/dist/themes',
prefixContainer: '#' + targetId,
version: getVersion(),
prefix: 'msgapi',
theme: query.theme
},
pluginsConfig: getPluginsConfiguration(localConfig.plugins, pluginsConfigKey),
lazyPlugins: pluginsDefinition.lazyPlugins,
pluginsDef: {
plugins: {
...pluginsDefinition.plugins
},
requires: {
...requires,
...pluginsDefinition.requires
}
},
printEnabled: true,
rootReducerFunc: standardRootReducerFunc,
onStoreInit,
appReducers: {
...standardReducers,
gnresource,
gnsettings,
security,
maptype,
print,
maplayout,
controls,
timeline,
dimension,
playback,
mapPopups,
catalog,
searchconfig,
widgets,
...pluginsDefinition.reducers
},
appEpics: {
...standardEpics,
...configEpics,
updateMapLayoutEpic,
gnCheckSelectedLayerPermissions,
gnSetLayersPermissions,
...pluginsDefinition.epics
themeCfg: {
path: '/static/mapstore/dist/themes',
prefixContainer: '#' + targetId,
version: getVersion(),
prefix: 'msgapi',
theme: query.theme
},
pluginsConfig: getPluginsConfiguration(localConfig.plugins, pluginsConfigKey),
lazyPlugins: pluginsDefinition.lazyPlugins,
pluginsDef: {
plugins: {
...pluginsDefinition.plugins
},
requires: {
...requires,
...pluginsDefinition.requires
}
},
printEnabled: true,
rootReducerFunc: standardRootReducerFunc,
onStoreInit,
appReducers: {
...standardReducers,
gnresource,
gnsettings,
security,
maptype,
print,
maplayout,
controls,
timeline,
dimension,
playback,
mapPopups,
catalog,
searchconfig,
widgets,
annotations,
...pluginsDefinition.reducers
},
appEpics: {
...standardEpics,
...configEpics,
updateMapLayoutEpic,
gnCheckSelectedLayerPermissions,
gnSetLayersPermissions,
...pluginsDefinition.epics
},
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
// later we could use expression in localConfig
updateGeoNodeSettings.bind(null, settings),
setControlProperty.bind(null, 'toolbar', 'expanded', false),
loadPrintCapabilities.bind(null, getConfigProp('printUrl')),
setResourcePermissions.bind(null, permissions),
...(geoNodePageConfig.isNewResource ? [setNewResource] : []),
configureMap.bind(
null,
geoNodePageConfig.resourceConfig,
1,
true
)
]
},
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
// later we could use expression in localConfig
updateGeoNodeSettings.bind(null, settings),
setControlProperty.bind(null, 'toolbar', 'expanded', false),
loadPrintCapabilities.bind(null, getConfigProp('printUrl')),
setResourcePermissions.bind(null, permissions),
...(geoNodePageConfig.isNewResource ? [setNewResource] : []),
configureMap.bind(
null,
geoNodePageConfig.resourceConfig,
1,
true
)
]
},
withExtensions(StandardApp));
});
});
withExtensions(StandardApp));
});
});
});
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/js/epics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const updateMapLayoutEpic = (action$, store) =>

const rightPanels = head([
get(state, "controls.details.enabled") && { right: mapLayout.right.md } || null,
get(state, "controls.annotations.enabled") && { right: mapLayout.right.md } || null,
get(state, "controls.annotations.enabled") && { right: mapLayout.right.md / 2 } || null,
get(state, "controls.metadataexplorer.enabled") && { right: mapLayout.right.md } || null,
get(state, "controls.measure.enabled") && showCoordinateEditorSelector(state) && { right: mapLayout.right.md } || null,
get(state, "mapInfo.enabled") && isMapInfoOpen(state) && { right: mapLayout.right.md } || null
Expand Down
4 changes: 4 additions & 0 deletions geonode_mapstore_client/client/js/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ export const plugins = {
DrawerMenuPlugin: toLazyPlugin(
'DrawerMenu',
import(/* webpackChunkName: 'plugins/drawer-menu-plugin' */ '@mapstore/framework/plugins/DrawerMenu')
),
AnnotationsPlugin: toLazyPlugin(
'Annotations',
import(/* webpackChunkName: 'plugins/annotations-plugin' */ '@mapstore/framework/plugins/Annotations')
)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,13 @@
"editingAllowedRoles": null,
"enableSetDefaultStyle": true
}
},
{
"name": "Annotations",
"cfg": {
"measurementAnnotationEdit": false,
"symbolsPath": "/static/mapstore/symbols/"
}
}
],
"geostory": [
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5eeb9d4

Please sign in to comment.