一、常用影像图层加载
1、添加高德地图
viewer.imageryLayers.addImageryProvider(new Cesium.UrlTemplateImageryProvider({
url: 'http://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}',
tilingScheme: new Cesium.WebMercatorTilingScheme()
})
);
2、添加天地图
//影像
viewer.imageryLayers.addImageryProvider(
new Cesium.WebMapTileServiceImageryProvider({
url: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=你的token",
layer: "tdtBasicLayer",
style: "default",
format: "image/jpeg"
}),
);
//注记
viewer.imageryLayers.addImageryProvider(
new Cesium.WebMapTileServiceImageryProvider({
url: "http://t0.tianditu.com/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg&tk=你的token",
layer: "tdtAnnoLayer",
style: "default",
format: "image/jpeg"
})
);
3、添加ArcServer地图
viewer.imageryLayers.addImageryProvider(new Cesium.ArcGisMapServerImageryProvider({
url : 'http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer'
})
4、添加Geoserver 地图
//wms地图服务
viewer.imageryLayers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
url : 'http://localhost:8080/geoserver/fs/wms',
layers : 'fs:county3',//图层
parameters : {
transparent : true,
format : 'image/png',
srs: 'EPSG:4490',
styles:''
}
})
);
//wmts服务
viewer.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider({
url:'http://localhost:8080/geoserver/gwc/service/wmts/rest/topp:states/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?format=image/png',
layer: 'topp:states',//图层名称
style: '',
format: 'image/png',
tileMatrixSetID: 'EPSG:4326',
tileMatrixLabels: ['EPSG:4326:0', 'EPSG:4326:1', 'EPSG:4326:2', 'EPSG:4326:3', 'EPSG:4326:4', 'EPSG:4326:5', 'EPSG:4326:6', 'EPSG:4326:7', 'EPSG:4326:8', 'EPSG:4326:9', 'EPSG:4326:10', 'EPSG:4326:11', 'EPSG:4326:12', 'EPSG:4326:13', 'EPSG:4326:14', 'EPSG:4326:15', 'EPSG:4326:16', 'EPSG:4326:17', 'EPSG:4326:18', 'EPSG:4326:19', 'EPSG:4326:20', 'EPSG:4326:21'],
tilingScheme: new Cesium.GeographicTilingScheme({
numberOfLevelZeroTilesX: 2,
numberOfLevelZeroTilesY: 1
})
})
二、Cesium ImageryProvider
加载不同格式的地图需要选择不同的接口,详见官方文档:
https://cesium.com/docs/cesiumjs-ref-doc/ImageryProvider.html
* ArcGisMapServerImageryProvider
* BingMapsImageryProvider
* TileMapServiceImageryProvider
* GoogleEarthEnterpriseImageryProvider
* GoogleEarthEnterpriseMapsProvider
* GridImageryProvider
* IonImageryProvider
* MapboxImageryProvider
* MapboxStyleImageryProvider
* SingleTileImageryProvider
* TileCoordinatesImageryProvider
* UrlTemplateImageryProvider
* WebMapServiceImageryProvider
* WebMapTileServiceImageryProvider
三、常用的影像地图服务:
1、高德:
矢量地图带注记:https://webrd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}
矢量地图不带注记:http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}&scl=1<ype=3
影像不带注记:http://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}
道路带注记:http://webst0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8
道路不带注记:http://wprd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=8<ype=11
矢量带注记http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}
2、天地图
//墨卡托投影
影像:http://{s}.tianditu.gov.cn/img_w/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default&format=tiles&tk=你的token" ;
矢量:http://{s}.tianditu.gov.cn/vec_w/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=vec&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default&format=tiles&tk=你的token" ;
影像中文标记:http://{s}.tianditu.gov.cn/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default.jpg&tk=你的token" ;
矢量中文标记:http://{s}.tianditu.gov.cn/cva_w/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=cva&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default.jpg&tk=你的token" ;
//经纬度
影像:http://{s}.tianditu.gov.cn/img_c/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=img&tileMatrixSet=c&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default&format=tiles&tk=你的token" ;
矢量:http://{s}.tianditu.gov.cn/vec_c/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=vec&tileMatrixSet=c&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default&format=tiles&tk=你的token" ;
影像中文标记:http://{s}.tianditu.gov.cn/cia_c/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=cia&tileMatrixSet=c&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default&format=tiles&tk=你的token" ;
矢量中文标记:http://{s}.tianditu.gov.cn/cva_c/wmts?service=wmts&request=GetTile&version=1.0.0" +
"&LAYER=cva&tileMatrixSet=c&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" +
"&style=default&format=tiles&tk=你的token" ;
3、智图
彩色版:http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer
暖色版:http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer
灰色版:http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer
蓝黑版:http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer
行政区:http://thematic.geoq.cn/arcgis/rest/services/ThematicMaps/administrative_division_boundaryandlabel/MapServer
地铁:http://thematic.geoq.cn/arcgis/rest/services/ThematicMaps/subway/MapServer
水系:http://thematic.geoq.cn/arcgis/rest/services/ThematicMaps/WorldHydroMap/MapServer
天地图图层加载:
百度地图的加载有点复杂,这篇博客有详细的解决方法:https://blog.csdn.net/KaiSarH/article/details/106242572