代码
import {
  BaiduMapConfig,
  BaiduVectorTileProvider,
  Engine,
  GeoJSONDataSource,
  Polyline,
} from '@baidumap/mapv-three';

const container = document.getElementById('map');
const center = [116.4224, 39.9085];
const range = (1400 * 1.42) / Math.min(1.42, container.clientWidth / container.clientHeight);
BaiduMapConfig.ak = '您的密钥';
const provider = new BaiduVectorTileProvider({
  displayOptions: {
    building: false,
    poi: false,
  },
});

const engine = new Engine(container, {
  map: {
    projection: 'EPSG:3857',
    center,
    range,
    pitch: 0,
    heading: 0,
    provider,
  },
  rendering: {
    sky: null,
  },
});

// 两侧向内描边,outlineWidth 与线宽同单位,取线宽的一半以内。
const line = engine.add(
  new Polyline({
    keepSize: true,
    lineWidth: 16,
    color: '#1f7bf2',
    outlineColor: '#ffffff',
    outlineWidth: 4,
  }),
);

// 沿北京长安街自西向东的一条折线,坐标系为 BD-09。
line.dataSource = GeoJSONDataSource.fromGeoJSON({
  type: 'Feature',
  geometry: {
    type: 'LineString',
    coordinates: [
      [116.4074, 39.9087],
      [116.414, 39.9086],
      [116.421, 39.9085],
      [116.428, 39.9084],
      [116.435, 39.9083],
    ],
  },
  properties: {},
});

沿北京长安街绘制一条宽线,用 Polyline 的 outlineColor 和 outlineWidth 给线两侧加白色描边。

预览