获取从新 ol.source.ImageWMS 创建的动态参数

Get dynamic params created from new ol.source.ImageWMS

根据this documentation of ol3,WIDTH、HEIGHT、BBOX 和 CRS(WMS 版本 < 1.3.0 的 SRS)的参数选项将被动态设置。

别人如何检索此信息?例如在地图坐标中获取图像的 BBOX。?

更新: 当我在我的代码中使用你的代码时,我得到一个 NaN 值

        var lay = new ol.layer.Image({
            extent: transform,
            source: new ol.source.ImageWMS({
                url: Layers.link,
                params: {'LAYERS': Layers.name},
                serverType: 'geoserver',
                imageLoadFunction: function(image, src) {
                    image.getImage().src = src;
                    // parse src for whatever you want to know
                    var bbox = src.match(/BBOX\=([^&^#]*)/)[1].split(',').map(Number);
                    console.log(bbox)
                }
            })
        });

如果您仅需要此信息进行调试,您可以通过查看发送的 WMS 请求在浏览器的开发人员工具中找到它:

如果您的应用程序需要此信息,您可以在 ImageWMS 源上定义自定义 imageLoadFunction 以检查请求的 URL:

new ol.source.ImageWMS({
  // ...
  imageLoadFunction: function(image, src) {
    image.getImage().src = src;
    // parse src for whatever you want to know
    var bbox = src.match(/BBOX\=([^&^#]*)/)[1].split(',').map(Number);
  }
});