I am trying to change the default background maps in the map viewer of GeoNetwork.
What I tried:
- in GeoNetwork web UI, login as admin, go to Settings / User Interface
- select ‘Create a default UI configuration’
- below ‘Choose an option to customize’ select ‘Map application / Viewer Map Configuration’
- as ‘Path to the context file (XML)’ enter ‘…/…/map/config-viewer-new.xml’
- Save settings
- switch to Map tab in GeoNetwork web UI
Expected results:
- below ‘Manage layers’, the new default background maps should be listed
Actual results:
- the list of background maps is empty, and no background layer is displayed on the map
- however, when pressing ‘Default map’, the new viewer config is loaded and background layers are working properly
- switching to e.g. the search tab and back, the list is empty again
Is there something I am missing here, or is it a bug in GeoNetwork? Has someone else successfully changed the default maps in map viewer?
Tested with GeoNetwork 4.2.8 docker image. The minimal docker compose config to reproduce the issue is:
networks:
gn-network:
driver: bridge
volumes:
geonetwork-catalogue-data:
services:
my-es-host:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.15
healthcheck:
test: ["CMD-SHELL", "curl -s -f http://localhost:9200/_cat/health >/dev/null || exit 1"]
interval: 30s
timeout: 10s
retries: 10
environment:
discovery.type: single-node
ingest.geoip.downloader.enabled: false
networks:
gn-network:
geonetwork-host:
image: geonetwork:4.2.8
ports:
- 8080:8080
depends_on:
my-es-host:
condition: service_healthy
volumes:
- ./config-viewer.xml:/var/lib/jetty/webapps/geonetwork/WEB-INF/data/data/resources/map/config-viewer-new.xml
- geonetwork-catalogue-data:/catalogue-data
environment:
ES_HOST: my-es-host
ES_PROTOCOL: http
ES_PORT: 9200
networks:
gn-network:
The content of the ./config-viewer.xml file is:
<ows-context:OWSContext xmlns:ows-context="http://www.opengis.net/ows-context"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ows="http://www.opengis.net/ows"
version="0.3.1" id="ows-context-ex-1-v3">
<ows-context:General>
<ows:BoundingBox crs="EPSG:3857">
<ows:LowerCorner>-10961266.408549732 -368509.62979839183</ows:LowerCorner>
<ows:UpperCorner>11305393.132677661 8768675.691270513</ows:UpperCorner>
</ows:BoundingBox>
</ows-context:General>
<ows-context:ResourceList>
<ows-context:Layer name="{type=osm}" group="Background layers" hidden="false"
opacity="1">
<ows:Title>OpenStreetMap
</ows:Title>
</ows-context:Layer>
<ows-context:Layer name="{type=tms,name=gm}" group="Background layers" hidden="false"
opacity="1">
<ows:Title xmlns:ows="http://www.opengis.net/ows">Google Maps
</ows:Title>
<ows-context:Server service="urn:ogc:serviceType:WMTS">
<ows-context:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="http://mt2.google.com/vt/lyrs=s@0&hl=en&x={x}&y={y}&z={z}" />
</ows-context:Server>
</ows-context:Layer>
</ows-context:ResourceList>
</ows-context:OWSContext>
Note that in this setup, the config-viewer.xml is mounted to /var/lib/jetty/webapps/geonetwork/WEB-INF/data/data/resources/map/config-viewer-new.xml in the docker container and gets copied to /catalogue-data/resources/map/config-viewer-new.xml by the GeoNetwork docker image on first startup (i.e. when the geonetwork-catalogue-data volume is empty). GeoNetwork is then configured to read the file from /catalogue-data/resources/map/config-viewer-new.xml as described above.