1

タイトルにあるように...ベクターレイヤーに関連付けられているデータにアクセスしようとしましたが、成功しませんでした。
次のエラーが発生します:「QUERY_LAYERSがリクエストされていないか、リクエストにクエリ可能なレイヤーがありません」

私はgeoserver、openlayers、そして以下に示すスクリプトを使用しています...。

           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);
            });

私が間違っていることについての提案は非常にありがたいです

よろしくクリス

4

3 に答える 3

1

request=getfeature を使用して WFS にデータの送信を依頼できますが、getfeatureinfo を使用している場合は WMS サーバーが必要です。GeoServer は両方のインターフェースを介してデータを提供できますが、2 つを混在させないことをお勧めします。

あなたが示すコードでは、最も可能性の高い問題は、配列が0から番号付けされているため、マップに2つのレイヤーがないことです.

于 2011-02-23T18:34:36.253 に答える
0

ソース URL (WFS サーバー) は実際に機能していますか? そこに行こうとすると、タイムアウトが発生します。

于 2010-08-30T20:42:17.173 に答える
0
// 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. //

}

于 2020-06-12T08:25:56.687 に答える