Skip to content

Add a vector tile source

Replicates the MapLibre example Add a vector tile source: country outlines drawn from a vector tileset on top of the basemap.

add-a-vector-tile-source.yaml
# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json
# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/add-a-vector-tile-source/
# A TileJSON url + source-layer, drawn over the same basemap's raster-free style.
type: map
id: add-a-vector-tile-source
config:
center: [0, 20]
zoom: 1
mapStyle: "https://demotiles.maplibre.org/style.json"
layers:
- id: country-outlines
type: line
source:
type: vector
url: "https://demotiles.maplibre.org/tiles/tiles.json"
source-layer: countries
paint:
line-color: "#ff69b4"
line-width: 1
  • Vector sources take a TileJSON url: (or a tiles: template list); the layer picks its layer inside the tileset with source-layer:.
  • minzoom/maxzoom, scheme, and promoteId are all available on the source when you need them.