# Integration

> Canonical URL: https://docs.mountaya.com/en/apis/tiles/integration/
> Last updated: 2026-11-27
> Rules for agents: https://docs.mountaya.com/llms.txt#rules-for-agents

Add Mountaya overlays to MapLibre GL JS, Mapbox GL JS, the MapTiler SDK, or deck.gl.

Every renderer follows the same steps: fetch an overlay's specification with your key, add its sources, then add its layers. These samples draw `hillshade` and `steepness`: swap the slug for any overlay in the [catalog](https://docs.mountaya.com/en/apis/tiles/overlays.md).

## MapLibre GL JS, Mapbox GL JS, and the MapTiler SDK

The three renderers share one style API, so this function runs on a `maplibregl.Map`, a `mapboxgl.Map`, or a `maptilersdk.Map`. Create the map with that renderer's own credentials first.

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

async function addOverlay(map, overlay) {
  const response = await fetch(
    `https://tiles.mountaya.com/v1/overlays/${overlay}/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 } : {}),
        paint: layer.paint ?? {},
        layout: layer.layout ?? {},
      });
    }
  }
}

map.on("load", () => addOverlay(map, "hillshade"));
```

The renderer fetches tiles itself and cannot send headers, so `withKey` adds your key to each tile URL.

## deck.gl

deck.gl builds layers rather than reading a style. Turn each source into a tile layer: an `MVTLayer` for vector tiles, and a `TileLayer` of `BitmapLayer` images for raster tiles.

```js
import { MVTLayer, TileLayer } from "@deck.gl/geo-layers";
import { BitmapLayer } from "@deck.gl/layers";

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

async function buildOverlayLayers(overlay) {
  const response = await fetch(
    `https://tiles.mountaya.com/v1/overlays/${overlay}/specification`,
    { headers: { "X-API-Key": KEY } },
  );
  const { data } = await response.json();

  return data.sources
    .filter((source) => source.type !== "raster-dem")
    .map((source) =>
      source.type === "raster"
        ? new TileLayer({
            id: source.id,
            data: source.tiles.map(withKey),
            minZoom: source.zoom_min,
            maxZoom: source.zoom_max,
            tileSize: source.size,
            renderSubLayers: (props) =>
              new BitmapLayer(props, {
                data: null,
                image: props.data,
                bounds: [
                  props.tile.boundingBox[0][0],
                  props.tile.boundingBox[0][1],
                  props.tile.boundingBox[1][0],
                  props.tile.boundingBox[1][1],
                ],
              }),
          })
        : new MVTLayer({
            id: source.id,
            data: source.tiles.map(withKey),
            minZoom: source.zoom_min,
            maxZoom: source.zoom_max,
          }),
    );
}

const layers = await buildOverlayLayers("steepness");
```

deck.gl does not read the specification's `paint` and `layout`, so style the features yourself. Draw a `raster-dem` source, such as hillshade's, with deck.gl's `TerrainLayer`.

## Stay within the limits

A map fetches tiles on its own schedule, so a busy map can reach your per-minute limit quickly. Read the `RateLimit` header where you fetch a specification, and slow down before a `429`. [Rate limits](https://docs.mountaya.com/en/apis/conventions/rate-limits.md) explains the headers.

- The function runs unchanged on MapLibre GL JS, Mapbox GL JS (which shares the style API) and the MapTiler SDK (which extends MapLibre GL JS). Construct the map with the renderer's own credentials; Mountaya's key authenticates only requests to Mountaya.
- A renderer fetches tiles itself and cannot set `X-API-Key`, so append `publishable_key` (and `session_token` where the organization requires one) to every tile template. A template may already carry a query string (`organization_id`), so join with `&` after a `?`.
- A `raster` or `raster-dem` source carries `size` (256 or 512) for `tileSize`. A vector layer names `source_layer`, which the renderers spell `source-layer`; raster layers carry an empty one. Pass `filter` when present. `paint` and `layout` may be null: pass `{}` in their place.
- For a time-varying overlay (weather, snow), add `timestamp` (RFC 3339) to the tile URLs beside the key, and replace the source's tiles when the selected time changes.
- deck.gl: `MVTLayer` for a `vector` source, `TileLayer` rendering a `BitmapLayer` for a `raster` source, each with `data` set to the keyed templates. A `raster-dem` source holds elevation rather than an image: skip it, or decode it with `TerrainLayer`. deck.gl layers do not consume the specification's MapLibre `paint` and `layout`; use the layer metadata (`type`, `key`, `legend`) as a guide for the accessors you set.
- The docs site bundles none of these libraries; the samples target the renderer in your own application.
- Limits: every answer the limits weighed under a key carries `RateLimit-Policy` and `RateLimit` (one entry per limit the request was counted against, such as `"minute";r=412;t=23`: 412 requests left in a window resetting in 23 seconds) and `X-Request-Id`. The headers are readable from a browser on any origin. A tile a shared cache may store (such as the published snapshot of a public itinerary) carries no rate-limit headers, since it is the same for every caller, and an organization whose agreement leaves the per-minute limit unlimited gets none either.
- Each `429` carries `Retry-After`: the whole seconds left in the minute, or, for a spent monthly allowance, the seconds until the organization's next billing period begins, which no renderer should retry before. `parseRateLimit` from `@mountaya/client` parses the two headers.
- The specification and tile endpoints are documented in full in the [Tile API reference](https://docs.mountaya.com/en/apis/tiles/reference.md).

## Next steps

- [Base maps](https://docs.mountaya.com/en/apis/tiles/base-maps.md): Draw a Mountaya base map under your overlays.
- [API reference](https://docs.mountaya.com/en/apis/tiles/reference.md): Every Tile API endpoint, from the OpenAPI specification.
