Configure a new plugin extension
This section shows how to add a plugin using the extension support in MapStore without re-compilation of the bundle of the geonode-mapstore-cient applications. This new extensibility should be used for simple plugins.
Setup extension
Navigate to the /opt/geonode-project/my_geonode/src/my_geonode/ directory
cd /opt/geonode-project/my_geonode/src/my_geonode/
An extension created based on the MapStoreExtension template and use the bundle as shown below. For example if the extension created is named SampleExtension
Extension bundle (SampleExtension) is copied to the extensions folder
/opt/geonode-project/my_geonode/src/
|-- ...
|-- my_geonode/
| |-- ...
| +-- static/
| |-- ...
| +-- mapstore/
| |-- ...
| +-- extensions/
| |-- SampleExtension/
| +-- index.json
|-- ...
Create an index.json file inside the /opt/geonode-project/my_geonode/src/my_geonode/static/mapstore/extensions directory
mkdir /opt/geonode-project/my_geonode/src/my_geonode/static/mapstore
mkdir /opt/geonode-project/my_geonode/src/my_geonode/static/mapstore/extensions
touch /opt/geonode-project/my_geonode/src/my_geonode/static/mapstore/extensions/index.json
/opt/geonode-project/my_geonode/src/
|-- ...
|-- my_geonode/
| |-- ...
| |-- client/
| +-- static/
| |-- ...
| +-- mapstore/
| |-- ...
| +-- extensions/
| |-- ...
| +-- index.json
|-- ...
Configure the extensions/index.json file to include the new extension
vim /opt/geonode-project/my_geonode/src/my_geonode/static/mapstore/extensions/index.json
Paste this configuration inside the index.json
{
"SampleExtension": {
"bundle": "SampleExtension/index.js",
"translations": "SampleExtension/translations",
"assets": "SampleExtension/assets"
}
}
Configure extension
Edit the /opt/geonode-project/my_geonode/src/my_geonode/templates/geonode-mapstore-client/_geonode_config.html template to include this new extension
vim /opt/geonode-project/my_geonode/src/my_geonode/templates/geonode-mapstore-client/_geonode_config.html
<!-- _geonode_config.html file in the my_geonode project -->
{% extends 'geonode-mapstore-client/_geonode_config.html' %}
{% block override_local_config %}
<script>
window.__GEONODE_CONFIG__.overrideLocalConfig = function(localConfig) {
localConfig.plugins.map_viewer.push({ "name": "SampleExtension" });
return localConfig;
};
</script>
{% endblock %}
Now the new extension will be available in the map_viewer page with the changes applied during the development