Skip to content

Instantly share code, notes, and snippets.

@gannebamm
Created January 7, 2022 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gannebamm/ef22d8c45c75b2537772ceb0f1e10851 to your computer and use it in GitHub Desktop.
Save gannebamm/ef22d8c45c75b2537772ceb0f1e10851 to your computer and use it in GitHub Desktop.
Example of mapstore2 overrides
<!-- _geonode_config.html file in geonode/templates/geonode-mapstore-client/_geonode_config.html -->
{% extends 'geonode-mapstore-client/_geonode_config.html' %}
{% block override_local_config %}
<script>
window.__GEONODE_CONFIG__.overrideLocalConfig = function(localConfig) {
// an example on how you can apply configuration to existing plugins
// example: DrawerMenu width (left panel)
var selectedPluginName = "TOC";
var pluginPageName = "map_view";
localConfig.plugins.map_edit.push({ "name": "SearchServicesConfig" });
// localConfig.plugins.map_view.push({ "name": "FloatingLegend" });
for (var i = 0; i < localConfig.plugins[pluginPageName].length; i++) {
var currentPlugin = localConfig.plugins[pluginPageName][i];
var isSelectedPlugin = currentPlugin.name === selectedPluginName;
if (isSelectedPlugin) {
// apply configuration to the plugin
localConfig.plugins[pluginPageName][i] = {
"name": selectedPluginName,
"cfg": {
"activateAddLayerButton": true,
"activateMetedataTool": true,
"activateSettingsTool": true,
"activateRemoveLayer": true,
"showFullTitleOnExpand": true
}
}
}
}
var selectedPluginName = "TOCItemsSettings";
for (var i = 0; i < localConfig.plugins[pluginPageName].length; i++) {
var currentPlugin = localConfig.plugins[pluginPageName][i];
var isSelectedPlugin = currentPlugin.name === selectedPluginName;
if (isSelectedPlugin) {
// apply configuration to the plugin
localConfig.plugins[pluginPageName][i] = {
"name": selectedPluginName,
"cfg": {
"hideTitleTranslations": false,
"showFeatureInfoTab": true
}
}
}
}
var selectedPluginName = "DrawerMenu";
for (var i = 0; i < localConfig.plugins[pluginPageName].length; i++) {
var currentPlugin = localConfig.plugins[pluginPageName][i];
var isSelectedPlugin = currentPlugin.name === selectedPluginName;
if (isSelectedPlugin) {
// apply configuration to the plugin
localConfig.plugins[pluginPageName][i] = {
"name": selectedPluginName,
"cfg": {
"menuOptions": {
"docked": true
}
}
}
}
}
return localConfig;
};
</script>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment