Cesium加载WMTS地图切片服务,通常有两种坐标系,即互联网常用的3857,局域网内常用的4326。
在Cesium.WebMapTileServiceImageryProvider 支持这两种tilingScheme加载,主要由以下两个参数控制:
1. 3857
this._tilingScheme = new Cesium.WebMercatorTilingScheme({
numberOfLevelZeroTilesX : 1,
numberOfLevelZeroTilesY : 1
});
2. 4326
this._tilingScheme = new Cesium.GeographicTilingScheme({
numberOfLevelZeroTilesX: 2,
numberOfLevelZeroTilesY: 1
});
3.例如加载geoserver发布的WMTS服务,4326坐标系,
var _matrixIds = ['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'
];
var _wmtsImageryProvider = new Cesium.WebMapTileServiceImageryProvider({
url: _layerInfo.layerUrl, //服务地址,如:'http://localhost:8080/geoserver/gwc/service/wmts'
layer: "wuhan_base:wuhan0-7", //图层名称,如:'tasmania'
style: '',
format: 'image/png',
tileMatrixSetID: 'EPSG:4326',
tileMatrixLabels: _matrixIds,
tilingScheme: new Cesium.GeographicTilingScheme({
numberOfLevelZeroTilesX: 2,
numberOfLevelZeroTilesY: 1
})
});
var _olayer = new Cesium.ImageryLayer(_wmtsImageryProvider);
_self.mapView.imageryLayers.add(_olayer);
!!!默认情况下,加载3857坐标系的切片
this._tilingScheme = new Cesium.GeographicTilingScheme({
numberOfLevelZeroTilesX: 2,
numberOfLevelZeroTilesY: 1
});