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

const container = document.getElementById('map');
const range = (1350 * 1.2) / Math.min(1.2, 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: [116.42084, 39.92338],
    range,
    pitch: 32,
    heading: 0,
    provider,
  },
  rendering: {
    sky: null,
    enableAnimationLoop: true,
  },
});

function point(coordinates, properties = {}) {
  return {
    type: 'Feature',
    geometry: {
      type: 'Point',
      coordinates,
    },
    properties,
  };
}

// 点位依次位于灯市口大街和金宝街一带的真实道路交叉口。
const crossings = [
  [116.4174535, 39.9249195, 52],
  [116.4241101, 39.9250149, 64],
  [116.4175779, 39.9217865, 46],
  [116.4242345, 39.9217865, 58],
];
const source = GeoJSONDataSource.fromGeoJSON(
  crossings.map(([lng, lat, size]) =>
    point([lng, lat, 4], {
      size,
    }),
  ),
);
source.defineAttribute('size');

// 未指定 model 时,EffectModelPoint 加载 SDK 自带的钻石模型。
const markers = engine.add(
  new EffectModelPoint({
    normalize: true,
    keepSize: true,
    vertexSizes: true,
    animationRotate: true,
    animationRotatePeriod: 3200,
  }),
);
markers.dataSource = source;

在北京灯市口大街及金宝街相邻的四处真实路口放置 EffectModelPoint,使用 SDK 自带的钻石模型,观察不同大小的模型原地旋转。

预览