Get started
Tile API

Quickstart

Quickstart

Add Mountaya's hillshade to a MapLibre GL JS map you already run. You fetch the overlay's specification, then register the sources and layers it lists.

1

Export your key

Use a publishable key with the tiles scope, from Organization → API keys in the Mountaya app.

export MOUNTAYA_PUBLISHABLE_KEY="pk_your_publishable_key"

2

Fetch the overlay specification

Each overlay describes the sources and layers to add, with their style already set.

curl https://tiles.mountaya.com/v1/overlays/hillshade/specification \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY"
Response
{
  "data": {
    "sources": [
      {
        "attribution": "<a href=\"https://www.maptiler.com/copyright/\" target=\"_blank\">&copy; MapTiler</a>",
        "id": "cb2e95b5-d2e0-404a-a22e-d1964e38ef39",
        "layers": [
          {
            "id": "overlay/58da3aaa-b470-4a3b-a689-7954ff6eebad",
            "key": "hillshade",
            "layout": null,
            "legend": {
              "locales": {
                "de": null,
                "en": {
                  "description": "The hillshade layer simulates the interaction of light with the terrain, where lighter areas indicate peaks and higher elevations, and darker areas represent valleys and lower terrain. The shading dynamically adjusts based on the timestamp control and the simulated light source angle, providing a more realistic 3D view of the landscape's topography."
                },
                "es": null,
                "fr": {
                  "description": "Le calque des zones d'ombre simule l'interaction de la lumière avec le terrain, où les zones plus claires indiquent les sommets et les hauteurs, tandis que les zones plus sombres représentent les vallées et les terrains plus bas. Les zones d'ombre s'ajustent dynamiquement en fonction du contrôle temporel des calques et de l'angle de la source lumineuse simulée, offrant ainsi une vue 3D plus réaliste du terrain."
                },
                "it": null,
                "ja": null,
                "zh": null
              }
            },
            "paint": {
              "hillshade-accent-color": "hsla(0, 0%, 100%, 0.0)",
              "hillshade-exaggeration": 1,
              "hillshade-highlight-color": "hsla(0, 0%, 100%, 0.0)",
              "hillshade-shadow-color": "hsla(130, 43%, 11%, 0.9)"
            },
            "source": "cb2e95b5-d2e0-404a-a22e-d1964e38ef39",
            "source_layer": "",
            "type": "hillshade",
            "zoom_max": 14,
            "zoom_min": 8
          }
        ],
        "size": 512,
        "tiles": [
          "https://tiles.mountaya.com/v1/overlays/hillshade/{z}/{x}/{y}"
        ],
        "type": "raster-dem",
        "zoom_max": 14,
        "zoom_min": 8
      }
    ]
  }
}

Hillshade has one raster-dem source, which holds elevation, and one hillshade layer drawn from it.

3

Draw it on your map

Add each source, then its layers, once the map has loaded. A map fetches tiles on its own and cannot send headers, so add your key to each tile URL as publishable_key.

const KEY = "pk_your_publishable_key";
const withKey = (url) => `${url}${url.includes("?") ? "&" : "?"}publishable_key=${KEY}`;

map.on("load", async () => {
  const response = await fetch(
    "https://tiles.mountaya.com/v1/overlays/hillshade/specification",
    { headers: { "X-API-Key": KEY } },
  );
  const { data } = await response.json();

  for (const source of data.sources) {
    map.addSource(source.id, {
      type: source.type,
      tiles: source.tiles.map(withKey),
      minzoom: source.zoom_min,
      maxzoom: source.zoom_max,
      attribution: source.attribution,
      ...(source.size ? { tileSize: source.size } : {}),
    });

    for (const layer of source.layers) {
      map.addLayer({
        id: layer.id,
        type: layer.type,
        source: source.id,
        ...(layer.source_layer ? { "source-layer": layer.source_layer } : {}),
        ...(layer.filter ? { filter: layer.filter } : {}),
        minzoom: layer.zoom_min,
        maxzoom: layer.zoom_max,
        paint: layer.paint ?? {},
        layout: layer.layout ?? {},
      });
    }
  }
});

Zoom in on the mountains: hillshade draws from its layer's zoom_min. To draw another overlay, change the slug in the specification URL.

Next steps

Last updated