正如标题所说..。我试图访问与矢量层相关的数据,但没有任何成功。
我得到以下错误:“没有请求QUERY_LAYERS,或者请求中没有可查询的层”
我使用的是geoserver、openlayer和下面显示的脚本……
map.events.register('click', map, function (e) {
document.getElementById('nodelist').innerHTML = "Loading... please wait...";
var params = {
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[1].options.typename,
FEATURE_COUNT: 50,
Layers: 'monitor:Routers',
Styles: '',
Srs: 'EPSG:4326',
WIDTH: map.size.w,
HEIGHT: map.size.h,
};
OpenLayers.loadURL("http://tobagoborn.com:8080/geoserver/wfs", params, this, setHTML, setHTML);
OpenLayers.Event.stop(e);
});如果有任何关于我做错了什么的建议,我将不胜感激。
致敬Chris
发布于 2011-02-24 02:34:36
您可以要求WFS使用request=getfeature向您发送数据,但如果您使用的是getfeatureinfo,则需要一个WMS服务器。GeoServer可以通过这两个接口提供数据,但最好不要混用这两个接口。
在代码中,您显示的最可能的问题是您的地图中没有2个图层,因为数组从0开始编号。
发布于 2010-08-31 04:42:17
您的源URL ( WFS服务器)真的在工作吗?当我超时( try to go there )时,我得到一个超时。
发布于 2020-06-12 16:25:57
// Your map object //
map = new ol.Map({})
// on click event call displayFeatureInfo method and pass the pixel as a
argument in this method //
map.on('click', function(event) {
displayFeatureInfo(event.pixel)
})
// execute the displayFeatureInfo method //
var displayFeatureInfo = function(pixel) {
var features = map.getFeaturesAtPixel(pixel, function(feature) {
return feature
})
console.log(features)
console.log(features.R)
// 1. when you see features in console, it is either object or array //
// 2. if got a multiple value on click event then it gives you a array and if
got a single value on click event then it gives you a object //
// 3. now we assume it is object, see (features.R) in console. information is
in single single character, then you can concat. //}
https://stackoverflow.com/questions/3593248
复制相似问题