2011-10-18 42 views

回答

4

在OpenLayers中,單個視口或地圖畫布上的處理程序事件觸發器。因此,您應該在每個圖層上附加事件(特性選擇和特性取消選擇)。如果您遵循代碼示例頁面中的內容,使用相同的事件,但不同的地方可能會改變你自己的代碼。

vectors1.events.on({ 
      "featureselected": function(e) { 
       showStatus("selected feature "+e.feature.id+" on Vector Layer 1"); 
      }, 
      "featureunselected": function(e) { 
       showStatus("unselected feature "+e.feature.id+" on Vector Layer 1"); 
      } 
     }); 

對於vectors2附加了相同的事件。如果您正在尋找該功能放置在哪一層,則代碼如此。

+0

正是我在尋找的東西。非常感謝你!你知道嗎,這是在OpenLayers文檔中的某處記錄的嗎? – madc

+1

確實,請檢查http://dev.openlayers.org/docs/files/OpenLayers/Events-js.html#OpenLayers.Events.on – Myra

+0

感謝您的幫助。 – madc

相關問題