Atlaslog
Atlaslog / MapLibre GL JS / API reference / VectorSource
MapLibre GL JS · API reference

VectorSource

Quick answer

VectorSource supplies tiled vector data via map.addSource(id, {type: 'vector', tiles, minzoom, maxzoom}). Geometry and attributes render on the client, so restyling needs no re-tiling, and the source backs fill, line, symbol and circle layers. Use loaded and hasTile to track tile progress.

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
map.addSource( id , { type: 'vector', tiles: [...], maxzoom: 6 })
Key points
Example
map.addSource('world', {
  type: 'vector',
  tiles: ['https://demotiles.maplibre.org/tiles/{z}/{x}/{y}.pbf'],
  minzoom: 0,
  maxzoom: 6,
  attribution: 'MapLibre demo tiles'
});

map.addLayer({
  id: 'world-fill',
  type: 'fill',
  source: 'world',
  'source-layer': 'countries',
  paint: {
    'fill-color': '#dbe7f3',
    'fill-outline-color': '#8aa4bf'
  }
});

map.addLayer({
  id: 'world-name',
  type: 'symbol',
  source: 'world',
  'source-layer': 'centroids',
  layout: {
    'text-field': ['get', 'NAME'],
    'text-size': 11
  }
});
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). VectorSource. https://www.jingweizhi.com/en/maplibre/api/vector-source.html (accessed 2026-11-03).