openlayers wms空间查询

openlayers wms空间查询



//绑定鼠标移动事件,获取坐标点

map.on('pointermove', function(evt) {

    if (evt.dragging) {
        return;
    }
    displayFeatureInfo(evt);

});

//查询

var displayFeatureInfo = function(evt) {

    //获取wms生成的资源url, fdLayer.getSource().getGetFeatureInfoUrl

    var url = fdLayer.getSource().getGetFeatureInfoUrl(evt.coordinate, map.getView().getResolution(),
        'EPSG:4326', {
            'INFO_FORMAT': 'application/json',

            'FEATURE_COUNT': 1
        });

    //http请求结果数据

    $.ajax({
        url: url,
        async: false,
        dataType: 'json',
        success: function(data) {

            if (data.features.length > 0) {

                //解析geojson结果

                var feature = data.features[0];

                //获取wms服务中想要的属性

                var fdid = feature.properties.fdid;
                var fdno = feature.properties.fdno;
            } else {
                content.innerHTML = '';
                overlay.setPosition(undefined);
            }
        }
    })

};

You may also like...

发表评论

您的电子邮箱地址不会被公开。

CAPTCHAis initialing...