Skip to content

Adding Custom Tile Servers

Max Patiiuk edited this page May 10, 2021 · 1 revision

Starting with Specify 7.6.0, users have an option to overwrite the default list of tile servers offered though Leaflet map. This also allows to add paid tile servers that require API keys.

By default, the list of servers is fetched from here: https://files.specifysoftware.org/specify7/7.6.0/leaflet-layers.json.

It can be overwritten by defining an app resource named leaflet-layers. The app resource should be defined under some collection (not a global resource).

Example leaflet-layers app resource:

{
  "baseMaps": {  // These are standalone layers
    "Layer Label": {
      "endpoint": "someEndpointURL",
      "serverType": "tileServer",  // or "wms" for WMS server
      "layerOptions": {
        // additional options can be defined here
        // Reference:
        // for tileServer: https://leafletjs.com/reference-1.7.1.html#tilelayer
        // for WMS server: https://leafletjs.com/reference-1.7.1.html#tilelayer-wms
      }
    },
    // Example:
    "Street Map (OpenStreetMap)": {
      "endpoint": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
      "serverType": "tileServer",
      "layerOptions": {
        "maxZoom": 19,
        "attribution": "&copy; <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"
      }
    },
  },
  "overlays": {  // These are available as overlays.
    // Overlay definition is identical to that of base maps,
    // except overlays are assumed to have transparent tiles,
    // thus, multiple overlays can be enabled on top of a
    // single base map.
  }
}