如何获得点击WMS图层名称。我尝试了不同的方式,但我没有收到。我有这样3个WMS图层

问题描述 投票:1回答:1

我有这样3个WMS图层如何获得这些层的WMS图层名称

var tiled = new ol.layer.Tile({
    visible : false,
    source : new ol.source.TileWMS({
        url : 'http://192.168.4.229:8080/geoserver/geodata/wms',
        params : {
            'FORMAT' : 'image/png',
            'VERSION' : '1.1.1',
            "LAYERS" : 'geodata:ht_line',
            tiled : true,
            "exceptions" : 'application/vnd.ogc.se_inimage',

        }
    })
javascript openlayers-3
1个回答
0
投票

你可以做到这一点与地图的forEachLayerAtPixel方法:

map.on('click', function(e) {
  map.forEachLayerAtPixel(e.pixel, function(layer) {
    // log the LAYERS param of the WMS source
    console.log(layer.getSource().getParams().LAYERS);
  });
});
© www.soinside.com 2019 - 2024. All rights reserved.