代码
import {
  BaiduMapConfig,
  BaiduVectorTileProvider,
  CSVDataSource,
  Engine,
  Label,
  SimplePoint,
} from '@baidumap/mapv-three';

BaiduMapConfig.ak = '您的密钥';

const container = document.getElementById('map');
const aspect = container.clientWidth / container.clientHeight;
const engine = new Engine(container, {
  map: {
    center: [110.507, 24.935],
    range: 13_500 / Math.min(1, aspect),
    pitch: 0,
    provider: new BaiduVectorTileProvider({
      displayOptions: {
        poi: false,
      },
    }),
  },
});

// WKT 坐标的第三维为高度(米)。
const csv = `name,coordinates
杨堤,POINT Z (110.476 24.948 5)
九马画山,POINT Z (110.526 24.932 5)
兴坪,POINT Z (110.535 24.920 5)`;

const dataSource = CSVDataSource.fromCSVString(csv);
dataSource.defineAttribute('text', 'name');

// 地图注记需要完整可读,避免斜视时圆点被底图截去一部分。
const points = engine.add(
  new SimplePoint({
    size: 13,
    color: '#1267c7',
    depthTest: false,
  }),
);
points.dataSource = dataSource;

const labels = engine.add(
  new Label({
    type: 'text',
    textSize: 14,
    pixelOffset: [0, 24],
    depthTest: false,
    textFillStyle: '#172e49',
    textStrokeStyle: '#ffffff',
    textStrokeWidth: 2,
  }),
);
labels.dataSource = dataSource;

用 CSV 的 POINT 坐标和地名绘制桂林漓江观景点,展示列属性到地图标签的映射。

预览