cesium加载天地图同时让天地图带地名信息
要加载带有地名信息的天地图,需要使用天地图提供的WMTS服务,并将带有地名信息的瓦片层添加到Cesium的场景中。
以下是一个示例代码:
// 创建Cesium Viewer
var viewer = new Cesium.Viewer('cesiumContainer');
// 创建天地图的WMTS服务
var tdt_wmts = new Cesium.WebMapTileServiceImageryProvider({
url: 'http://t{s}.tianditu.com/DataServer?T=vec_c&x={TileCol}&y={TileRow}&l={TileMatrix}',
layer: 'tdt_vec_c',
style: 'default',
format: 'tiles',
tileMatrixSetID: 'c',
maximumLevel: 18,
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
credit: new Cesium.Credit('天地图全球矢量地图服务'),
tilingScheme: new Cesium.WebMercatorTilingScheme(),
show: false
});
// 创建带有地名信息的瓦片层
var tdt_annotation = new Cesium.WebMapTileServiceImageryProvider({
url: 'http://t{s}.tianditu.com/DataServer?T=cva_c&x={TileCol}&y={TileRow}&l={TileMatrix}',
layer: 'tdt_cva_c',
style: 'default',
format: 'tiles',
tileMatrixSetID: 'c',
maximumLevel: 18,
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
credit: new Cesium.Credit('天地图全球矢量注记服务'),
tilingScheme: new Cesium.WebMercatorTilingScheme(),
show: false
});
// 将WMTS服务添加到Cesium Viewer中
viewer.imageryLayers.addImageryProvider(tdt_wmts);
viewer.imageryLayers.addImageryProvider(tdt_annotation);
在上述代码中,我们首先创建了一个Cesium Viewer,并创建了天地图的WMTS服务。然后,我们创建了带有地名信息的瓦片层,并将它们添加到Cesium Viewer的imageryLayers中。
最后,我们可以通过设置show属性来控制是否显示这些瓦片层。
这样,就可以加载带有地名信息的天地图了
原文地址: https://www.cveoy.top/t/topic/fJ0d 著作权归作者所有。请勿转载和采集!