代码
import {Engine, MapboxVectorTileProvider} from '@baidumap/mapv-three';

const provider = new MapboxVectorTileProvider({
  maxLevel: 14,
  style: {
    version: 8,
    sources: {
      openmaptiles: {
        type: 'vector',
        url: 'https://tiles.openfreemap.org/planet',
      },
    },
    layers: [
      {
        id: 'land',
        type: 'background',
        paint: {
          'background-color': '#edf2ef',
        },
      },
      {
        id: 'parks',
        type: 'fill',
        source: 'openmaptiles',
        'source-layer': 'park',
        paint: {
          'fill-color': '#b8d5bb',
        },
      },
      {
        id: 'water',
        type: 'fill',
        source: 'openmaptiles',
        'source-layer': 'water',
        paint: {
          'fill-color': '#78b8d0',
        },
      },
      {
        id: 'roads',
        type: 'line',
        source: 'openmaptiles',
        'source-layer': 'transportation',
        paint: {
          'line-color': '#fffaf0',
          'line-width': 1.4,
        },
      },
      {
        id: 'buildings',
        type: 'fill',
        source: 'openmaptiles',
        'source-layer': 'building',
        minzoom: 12,
        paint: {
          'fill-color': '#a6aeb9',
        },
      },
    ],
  },
});

new Engine('map', {
  map: {
    projection: 'EPSG:3857',
    center: [13.397, 52.518],
    pitch: 0,
    range: 10_000,
    provider: provider,
  },
});

使用 MapboxVectorTileProvider 加载 OpenFreeMap 的 MVT。示例用样式版本 8 分别绘制公园、水系、道路与建筑,数据源通过公开 TileJSON 提供当前瓦片地址。

预览