我與unByKey/ol.Observable東西又掙扎......未聽事件而修改的交互,並重新對聽後
我有一個事件監聽器,用於創建彈出窗口。
var unByKeyPopup;
unByKeyPopup = map.on('click', function (evt) {
...
});
然後我有一個修改交互,當一個複選框被設置爲true時被激活。
function xyz() {
....
$('#checkbox').on('click', function() {
if(this.checked) {
modifyVectorInteraction();
$('#checkbox').un('click', unByKeyPopup); //????? dont activate the Popup thing while the user is in modify interaction
} if(!this.checked) {
map.removeInteraction(modifyinteraction);
$('#checkbox').on('click', unByKeyPopup); //????? ok, modify done, lets re-activate the Popup
}
...
});
...
}
嗯......這是最後的工作。我究竟做錯了什麼?
謝謝
好吧我對POPOP聽者一種解決方法。我在圖層中添加了以下屬性: 'nopopup:true' 並具有以下atm: 'unByKeyPopup = map.on('click',function(evt){function,layer} { if(layer.get('nopopup')!== true){ ... ' 或多或少,但更優雅的將是unByKey解決方案 – MichaelJS