Get started
Tile API

Integration

Integration

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.

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.

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.

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 explains the headers.

Next steps

Last updated