代码
import {Engine, MapView, XYZImageryTileProvider} from '@baidumap/mapv-three';
const engine = new Engine('map', {
map: {
projection: 'EPSG:3857',
center: [13.5, 46.5],
pitch: 0,
range: 3_600_000,
provider: null,
},
});
const provider = new XYZImageryTileProvider({
url: 'https://tiles.openfreemap.org/natural_earth/ne2sr/{z}/{x}/{y}.png',
projection: 'EPSG:3857',
maxLevel: 6,
});
engine.add(
new MapView({
imageryProviders: [provider],
}),
);
使用 XYZImageryTileProvider 接入 Natural Earth 晕渲栅格,查看欧洲地形和海岸线。接入自己的 XYZ 服务时可替换 URL 和最大层级,XYZ 从北向南编号的行号对应 SDK 占位符 {y}。
预览