Cesium加载Geoserver wtms服务和wms服务

Cesium加载Geoserver wtms服务和wms服务

  • 代码如下
    • Geoserver WMS
    • Geoserver WMTS

代码如下

Geoserver WMS

 const layer = viewer.imageryLayers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
                        url: 'http://127.0.0.1:8080/geoserver/workspace/wms',
                        layers: 'workspace:city',
                        parameters: {
                            service: 'WMS',
                            format: 'image/png',
                            transparent: true,
                        },
                    }));

workspace为工作区
city为图层名称
注意此时的参数为layers ,加载图层的对象为WebMapServiceImageryProvider

Geoserver WMTS

 const layer = viewer.imageryLayers.addImageryProvider(
                        new Cesium.WebMapTileServiceImageryProvider({
                            url: 'http://127.0.0.1:8080/geoserver/gwc/service/wmts',
                            layer: 'workspace:city',
                            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'],
                            maximumLevel: 22,
                            show: false,
                            tilingScheme: new Cesium.GeographicTilingScheme(),
                        }));

注意此时的参数为layer,加载图层的对象为WebMapTileServiceImageryProvider

你可能感兴趣的:(Cesium)