【问题标题】:How to set wms parameter (bbox, width, height, x, y)如何设置wms参数(bbox、width、height、x、y)
【发布时间】:2019-10-22 06:11:39
【问题描述】:

我在创建 wms url 后访问地理服务器。然后我使用 getFeatureInfo 来获取信息。 如何设置参数以获取多个图层信息?

什么是宽度、高度、x、y、bbox?

var bboxControl = 0.0001;

var bbox = (coordinate[0]-bboxControl) + ',' +  
(coordinate[1]-bboxControl) + ',' +  
(coordinate[0]+bboxControl) + ',' +
(coordinate[1]+bboxControl);

var projection = map.getView().getProjection().getCode();

const parameter = "?SERVICE=WMS
&VERSION=1.1.1
&REQUEST=GetFeatureInfo
&FORMAT=image/png
&TRANSPARENT=true" 
+ "&QUERY_LAYERS=" + layers
+ "&LAYERS=" + layers
+ "&exceptions=application/vnd.ogc.se_inimage
&INFO_FORMAT=application/json
&FEATURE_COUNT=50
&X=50&Y=50"
+ "&SRS=" + projection
+ "&STYLE=&WIDTH=101&HEIGHT=101"
+ "&BBOX=" + bbox;

$(document).ready(function(){
    $.ajax({
        url: getFeatureInfoUrl + parameter,
        dataType : 'json',
        success: function(result){
            success(result);
        }           
    });
});

这可行,但不取决于缩放状态。

【问题讨论】:

    标签: javascript openlayers wms


    【解决方案1】:

    如果你想要更多的层,在你的代码的某个地方你有一个名为layers 的列表/数组。添加你想要的每一层。

    对于您的第二个问题,请检查 here 以获取 GeoServer 请求。
    但简而言之:

    • BBox 表示边界框。它定义了 GeoServer 发送数据的区域。
    • 宽度和高度定义从 GeoServer 返回的地图大小。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-22
      • 2014-07-05
      • 1970-01-01
      • 1970-01-01
      • 2012-12-14
      相关资源
      最近更新 更多