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

与 Mapbox 一起使用

Mapbox GL JS 是一个用于在 Web 上绘制交互式、可自定义矢量地图的 JavaScript 库。 Mapbox GL JS v1.x 是开源的,后来被分叉为 MapLibre,因此与 Mapbox 一起使用 Martin 类似于 MapLibre。 Mapbox GL JS 可以接受 Martin 生成的 MVT 矢量瓦片,并对其应用样式以使用 Web GL 绘制地图。

您可以向地图添加图层并将 Martin TileJSON 端点指定为矢量源 URL。 您还应该指定 source-layer 属性。 对于表源,默认情况下为 {table_name}。

map.addLayer({
    id: 'points',
    type: 'circle',
    source: {
        type: 'vector',
        url: 'http://localhost:3000/points'
    },
    'source-layer': 'points',
    paint: {
        'circle-color': 'red'
    }
});