cesium中点击获取wms图层信息

1,126 阅读1分钟

1,加载瓦片数据

2, 点击图层查询属性,主要是cesium的api和wms服务。API是:UrlTemplateImageryProvider

curLayer = new Cesium.UrlTemplateImageryProvider({                
    url: `${newUrl}?layer=${treeNode.publishInfo.name}&
        style=default&tilematrixset=default028mm&
        Service=WMTS&Request=GetTile&Version=1.0.0&
        Format={format}&TileMatrix={TileMatrix}&
        TileRow={y}&TileCol={x}&tk=${ddj_token}`,                
    layer: treeNode.publishInfo.name,                
    style: "default",                
    format: "image/png",                
    tileMatrixSetID: "default028mm",                
    tilingScheme: new Cesium.GeographicTilingScheme(),
    //自定义参数,定制层级和行列                
    customTags:{                    
        TileMatrix:function(imageryProvider, x, y, level){                        
            return level+1;                    
        },                    
        format: function(){                        
            return "image/png"                    
        },                
    },                
    //图层点击拾取,根据服务需求传参                
    pickFeaturesUrl: `${treeNode.publishInfo.wmsURL}?layers=0&
        query_layers=0&style=&crs=EPSG:4326&
        Service=WMS&Request=GetFeatureInfo&Version=1.3.0&
        info_format=text/html&i={i}&j={j}&width={width}&height={height}&
        bbox={southDegrees},{westDegrees},{northDegrees},{eastDegrees}`,                
    //图层拾取回调                
    getFeatureInfoFormats: [
        new Cesium.GetFeatureInfoFormat( "html", "text/html", callback)
    ]            
})