簡體   English   中英

OpenLayers:GetFeature WFS請求在鼠標輸入之前不會觸發featureselected事件

[英]OpenLayers: GetFeature WFS request doesn't trigger the featureselected event prior to mouse input

我已經使用WFS協議設置了GetFeature控件,在添加並激活該控件后,單擊鼠標即可正常工作。

selectControl.events.register("featureselected", this, function (e) { 
vectorLayer.addFeatures([e.feature]); 
}); 
selectControl.events.register("featureunselected", this, function (e) { 
    vectorLayer.removeFeatures([e.feature]); 
}); 
map.addControl(selectControl); 
selectControl.activate(); 

我想從新創建的點位置自動請求控件,如下所示:

map.controls[5].request(new OpenLayers.Bounds([lonLat.lon, lonLat.lat, lonLat.lon, lonLat.lat]), { single: true });

這有效,但是僅在我至少使用鼠標輸入觸發一次請求之后。 在手動請求之前,自動請求將不會觸發featureselected事件。

一旦用鼠標單擊觸發了事件,就可以將控制請求方法與邊界輸入一起使用。

因為我已經花了很多時間在此方面,所以任何輸入都值得歡迎。

謝謝,丹尼斯

我自己發現了問題。 我不確定這是否是OpenLayers腳本中的錯誤。

當我這樣請求控件時,GetFeature控件的Modifys屬性為null:

.request(new OpenLayers.Bounds([lonLat.lon, lonLat.lat, lonLat.lon, lonLat.lat]), { single: true });

而不是單擊地圖對象。

一旦我通過單擊地圖來調用控件,修飾符屬性將設置為{multiple:null,toggle:null}。

如果我像這樣在控件上聲明修飾符屬性:

.modifiers = {multiple:null,toggle:null}

我可以在不單擊地圖的情況下運行.request。

這是我的疏忽嗎? OL文檔沒有聲明應手動聲明修飾符。 但是,文檔頁面中未提供默認值。

丹尼斯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM