Cesium加载各类服务数据
一、地形数据
1. 源码
//初始化地形数据 const demLayer: CesiumTerrainProvider = new Cesium.CesiumTerrainProvider({ url: url, requestVertexNormals: true, }); //加载地形数据 viewer.terrainProvider = demLayer //隐藏 直接置空 viewer.terrainProvider = new Cesium.EllipsoidTerrainProvider({}); //恢复重新赋值
二、ImageryLayer 类型数据
ArcGisMapServerImageryProvider
BingMapsImageryProvider
OpenStreetMapImageryProvider
TileMapServiceImageryProvider
GoogleEarthEnterpriseImageryProvider
GoogleEarthEnterpriseMapsProvider
GridImageryProvider
IonImageryProvider
MapboxImageryProvider
MapboxStyleImageryProvider
SingleTileImageryProvider
TileCoordinatesImageryProvider
UrlTemplateImageryProvider
WebMapServiceImageryProvider
WebMapTileServiceImageryProvider
1.UrlTemplateImageryProvider
dom影像数据 代码
// xyz格式 const url = 'https://yoururl/{Time}/{z}/{y}/{x}.png' const provider: UrlTemplateImageryProvider = new Cesium.UrlTemplateImageryProvider({ url: url, rectangle: rec, maximumLevel: maxlevel, minimumLevel: minlevel, }) as UrlTemplateImageryProvider;
viewer.scene.imagerlayers.addImageryProvider(provider)
2.ArcGisMapServerImageryProvider
//arcgis mapserver let arcgisMapServer = new Cesium.ArcGisMapServerImageryProvider({ url: url, tilingScheme: new Cesium.WebMercatorTilingScheme(), }); viewer.scene.imageryLayers.addImageryProvider(arcgisMapServer);
3.WebMapTileServiceImageryProvider
//kvp const shadedRelief1 = new Cesium.WebMapTileServiceImageryProvider({ url : 'http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS', layer : 'USGSShadedReliefOnly', style : 'default', format : 'image/jpeg', tileMatrixSetID : 'default028mm', // tileMatrixLabels : ['default028mm:0', 'default028mm:1', 'default028mm:2' ...], maximumLevel: 19, credit : new Cesium.Credit('U. S. Geological Survey') }); viewer.imageryLayers.addImageryProvider(shadedRelief1); //restful const shadedRelief2 = new Cesium.WebMapTileServiceImageryProvider({ url : 'http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS/tile/1.0.0/USGSShadedReliefOnly/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg', layer : 'USGSShadedReliefOnly', style : 'default', format : 'image/jpeg', tileMatrixSetID : 'default028mm', maximumLevel: 19, credit : new Cesium.Credit('U. S. Geological Survey') }); viewer.imageryLayers.addImageryProvider(shadedRelief2);
4.WebMapServiceImageryProvider
let wmsProvider= new Cesium.WebMapServiceImageryProvider({ url:url, layers: layer, parameters: parameters, rectangle:rectangle, }); viewer.scene.imageryLayers.addImageryProvider( wmsProvider );