跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
搜索与研究

maplibre-tile-sources

How to choose and configure data sources for MapLibre GL JS — rendering your own data without tiles, hosted tile services, serverless PMTiles, self-hosted tile servers, tile schemas, and sprites.

maplibre · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add maplibre/maplibre-agent-skills --skill maplibre-tile-sources

技能说明


name: maplibre-tile-sources description: How to choose and configure data sources for MapLibre GL JS — rendering your own data without tiles, hosted tile services, serverless PMTiles, self-hosted tile servers, tile schemas, and sprites. status: verified

MapLibre Tile Sources

MapLibre GL JS does not ship with map data. You provide a style that references sources — URLs or inline data that MapLibre fetches and renders. MapLibre works equally well for a store locator with 200 addresses, a city transit map, and a global basemap — the right source type depends on geographic scale and level of detail, update frequency, infrastructure constraints, and use case.

When to Use This Skill

  • Setting up a new MapLibre map and choosing where your data comes from
  • Deciding between GeoJSON, serverless tiles, hosted services, a combination thereof, or self-hosted options
  • Configuring sprites so icons render (for glyphs/fonts, see maplibre-fonts-glyphs)
  • Debugging blank maps or missing tiles
  • Migrating from Mapbox and need equivalent tile sources and style setup

How styles and sources work

A style (a style JSON, style document, or style object) is the configuration you pass to MapLibre. It contains the specific rendering rules governed by the MapLibre Style Specification, maintained with parity for MapLibre GL JS and MapLibre Native.

You can use a style URL from a provider — that URL references a style with sources, layers, glyphs, and sprite. Or you can build your own style and configure each yourself.

A style has three main components:

  • Sources — Point to the actual data. Each source has a type and either inline data or a URL. MapLibre requests tiles or data as the viewport changes. The same source can back many layers (e.g. roads, water, and labels all from one vector URL).
  • Layers — An ordered list defining what to draw and how. Each layer references a source (and for vector tiles, a source-layer name) and specifies paint/layout properties.
  • Glyphs and sprite — URLs to font SDF stacks and icon spritesheets. sprite has no fallback: a missing icon is silently omitted. glyphs does have one on GL JS ≥ 5.11.0 (text still renders, in a local/system font) — see maplibre-fonts-glyphs for the mechanism and its limits. Production styles should still supply both explicitly.

Source types:

TypeDescription
vectorVector tiles — binary-encoded geometry and attributes; the primary format for basemaps and data overlays
rasterRaster tile imagery — satellite photos, WMS/WMTS layers
raster-demElevation tiles — for terrain rendering and hillshading
geojsonGeoJSON data — inline object or URL; no tile server needed
imageA single georeferenced image — scanned maps, annotated overlays
videoGeoreferenced video

vector and raster are the most common for basemaps and data overlays. geojson is ideal for small datasets or interactive data that doesn't need tiling. raster-dem is used for terrain and hillshade effects, as well as emerging use cases in scientific visualization. image and video sources are the least common, but let you georeference static images (such as a scanned map, chart, or overlay) or georeferenced videos as map layers.

GeoJSON and Direct Data Sources

For many use cases you don't need a tile service. MapLibre can render points, lines, or polygons directly from an inline GeoJSON object or a URL to a GeoJSON file. The entire dataset is downloaded and parsed in the browser; MapLibre handles rendering client-side.

map.addSource('my-data', {
  type: 'geojson',
  data: '/path/to/data.geojson' // or an inline GeoJSON object
});
map.addLayer({
  id: 'my-layer',
  type: 'fill',
  source: 'my-data',
  paint: { 'fill-color': '#0080ff', 'fill-opacity': 0.5 }
});

GeoJSON performance thresholds

GeoJSON downloads the entire file on every load. This works well at small scale and degrades predictably:

RangeFile size / feature countBehavior
Sweet spot< 2 MB / < 5,000 featuresInstantaneous loading, smooth interaction
Lag zone5–20 MB / up to ~50,000 features1–3s parse delay; mobile may struggle; optimize by simplifying geometries and reducing coordinate precision
Crash zone> 50 MB / > 100,000 featuresHigh risk of browser freeze or crash; switch to vector tiles

GeoJSON is lossless (exact coordinates preserved) and gives you full client-side access to feature properties — ideal for interactive data, dynamic updates, and datasets where you need to query or modify features without a server round-trip.

If your dataset exceeds these thresholds, or if you need zoom-dependent rendering (less detail at lower zoom levels), consider vector tiles instead.

Other formats and the cloud-native ecosystem

The choice of data source is shaped by more than performance: data type, update frequency, access patter

阅读完整来源 ↗