Add a new default TMS ZXY baselayer

12 views
Skip to first unread message

Scott Whittaker

unread,
Sep 25, 2024, 9:05:52 PM9/25/24
to GeoNode Development
I'm trying to add some new basemap layers from a local mapping provider that are higher resolution than the default basemaps.

I have successfully added these as overlay layers using the Add Layers UI. The configuration for these is very simple, here is one example:

Type: TMS
Title: LINZ Aerial Basemap
Provider: Custom
Custom TMS Configuration:
{
  "options": {
    "maxZoom": 15,
    "maxNativeZoom": 15
  }
}

Now I want to add these layers to the default basemap list (or replace the defaults with these equivilents).

I was told the way to add basemaps is through code configutation, updating the MAPSTORE_BASELAYERS variable.

I spent the entire day yesterday trying to figure out which file to update and where it should be stored in which docker container. I finally managed to do it by creating a local_settings.py file and link that into the x-common-django docker container as a volume reference:

x-common-django:
...
  volumes:
...
    - ./conf/local_settings.py:/usr/src/geonode_groundtruth/geonode_groundtruth/local_settings.py

I know this is working because I have been able to delete some of the default layers in local_settings.py defaults and change their icons, and confirmed these changes are showing up when I restart the containers.

Unfortunately I have no idea what the new layer definition should look like. The only documentation I have found is here:

and here:

But none of the example base layer definitions are of type TMS, and I don't see TMS in the list of supported layer types in the documentation. Though I have been searching for baselyer and TMS and local_settings.py issues in github issues, and found comments to suggest that TMS is supported - and it obviously is supported as an overlay layer.

To add to that many of the layer definitions seem to be insufficient to completely describe a layer. e.g:
        {
            "type": "osm",
            "title": "Open Street Map",
            "name": "mapnik",
            "source": "osm",
            "group": "background",
            "visibility": True,
        },
There is not even a URL in this description, so how does the server know where to pull layer data from? That coupled with the last line in my local_settings.py file:

MAPSTORE_BASELAYERS_SOURCES = os.environ.get("MAPSTORE_BASELAYERS_SOURCES", {})

Scott Whittaker

unread,
Sep 25, 2024, 9:11:21 PM9/25/24
to GeoNode Development, Scott Whittaker
Sorry I posted the message before finishing my post.

Anyway the above existence of the MAPSTORE_BASELAYERS_SOURCES variable and incompleteness of the OSM layer description leads me to believe that the layer description is only half of what's needed to add a new baselayer, and needs to go along with a source definition. But I can find no examples or documentation of what a source definition should look like.

Can someone please show me the configuration code that needs to go into local_settings.py to add a TMS base layer with the following definition:

Type: TMS
Title: LINZ Aerial Basemap
Provider: Custom
Custom TMS Configuration:
{
  "options": {
    "maxZoom": 15,
    "maxNativeZoom": 15
  }
}

Thanks!

Scott

Scott Whittaker

unread,
Sep 26, 2024, 12:18:01 AM9/26/24
to GeoNode Development, Scott Whittaker
I figured it out:

{
    "type": "tileprovider",
    "title": "LINZ Aerial",
    "provider": "custom",
    "name": "LINZ",
    "group": "background",
    "visibility": False,
    "url": "https://tiles.maps.linz.io/nz_aerialimagery_basemap/GLOBAL_MERCATOR/{z}/{x}/{y}.png",
Reply all
Reply to author
Forward
0 new messages