添加
// vec(矢量)、img(影像)、cia(影像中文注记)、cva(矢量中文注记)
let type = 'img';
// 注意:_w 使用球面墨卡托,_c 无效
// 旧后缀 tianditu.com,不支持 https。新后缀 tianditu.gov.cn,兼容 http 和 https
let url = `${window.location.protocol}//{s}.tianditu.gov.cn/${type}_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=${type}&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=${options.token}`;
// vec(矢量)、img(影像)、cia(影像注记)、cva(矢量注记)
let layerProvider = new Cesium.WebMapTileServiceImageryProvider({
url,
layer: `tdtBasicLayer${type}`,
style: "default",
format: "tiles",
tileMatrixSetID: "w",
maximumLevel: 18, // 必须加上最大级数
subdomains: ["t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7"]
});
let layer = viewer.imageryLayers.addImageryProvider(layerProvider);
注意
- 代码第 3 - 5 行,新地址为 tianditu.gov.cn,使用球面墨卡托 w;
- 代码第 13 行,必须设置,否则放到最大级别,出现图片报错误 “此级别下,该区域无影像”(下图所示);