我創建了一個文本框,我可以放置座標X,Y,然後將該圖釘移動到該位置並查找哪些道路在那裏。Openlayers 3:爲什麼forEachFeatureAtPixel只返回一個特徵
引腳移動,但forEachFeatureAtPixel
只返回一個功能,而不是四個。此外,我得到的功能沒有NOMBRE
屬性
我使用的是Openlayer 3和我的WMS服務器映射。
正如您在MapInfo中所看到的(圖片右側),我獲得了所有4個功能。
水平2x「Calle 6」和垂直2x「Calle 1 Norte」,並具有NOMBRE
屬性。
我在mapinfo中使用了所有4個特徵相同的x,y。
新的信息:我的層ol.layer.Tile代替ol.layer.Vector,或許這就是(檢查)
wmsLyr09 = new ol.layer.Tile({
source: wmsSource
});
// move the pin to new position
geometry.translate(deltaX, deltaY);
var coordinate = geometry.getCoordinates();
var pixel = map.getPixelFromCoordinate(coordinate);
console.log('pixel: ' + pixel);
var allFeaturesAtPixel = [];
map.forEachFeatureAtPixel(pixel, function (feature) {
allFeaturesAtPixel.push(feature);
});
// feature[len]:1
console.log("feature[len]:" + allFeaturesAtPixel.length);
//feature[Name]: undefined
feature= allFeaturesAtPixel[0];
console.log("feature[Name]: " + feature.get('NOMBRE'));
WFS GetFeature,不帶幾何或允許選擇,是嗎?我更新我的工具,使該地區的幾條道路鏈接,並創建另一個時間矢量圖層,因此用戶可以選擇道路鏈接。 – 2015-02-10 18:38:32
你也可以得到幾何。創建GetFeature請求並用'ol.format.GML'解析返回的GML:http://openlayers.org/en/master/apidoc/ol.format.GML.html?unstable=true – tsauerwein 2015-02-12 08:10:24