Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

与 deck.gl 一起使用

deck.gl 是一个用于大型数据集视觉探索性数据分析的 WebGL 驱动框架。

您可以使用 MVTLayer 添加矢量瓦片。MVTLayer data 属性定义 MVT 图层的远程数据。它可以是

  • String:URL 模板或 TileJSON URL。
  • Array:URL 模板数组。它允许跨不同瓦片端点平衡请求。例如,如果您定义一个包含 4 个 url 的数组并且需要加载 16 个瓦片,则每个端点负责提供 16/4 个瓦片。
  • JSON:有效的 TileJSON 对象。
const pointsLayer = new MVTLayer({
  data: 'http://localhost:3000/points',
  pointRadiusUnits: 'pixels',
  getRadius: 5,
  getFillColor: [230, 0, 0]
});

const deckgl = new DeckGL({
  container: 'map',
  mapStyle: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
  initialViewState: {
    latitude: 0,
    longitude: 0,
    zoom: 1
  },
  layers: [pointsLayer]
});