HERE 地图 removeEventListener 不起作用
HERE maps removeEventListener doesn't work
我正在尝试从地图中删除“addEventListerner”,但它不起作用有我的代码:
function dbltapzoom(){
alert("Remove");
}
map.addEventListener('pointerdown', function (evt) {
var coord = map.screenToGeo(evt.currentPointer.viewportX,
evt.currentPointer.viewportY);
polygonStroke.setGeometry(coord);
polygonStroke.setVisibility(true);
locationVertices.push(polygonStroke);
map.addObject(polygonStroke);
},false);
map.addEventListener('dbltap', function () {
map.removeEventListener('pointerdown',dbltapzoom,false);
});
老实说,我不知道该怎么做。任何帮助和解释我做错了什么都会很好。感谢您的帮助:)
您只能删除同一个注册的侦听器。就像您在 pointerdown
上注册到映射列表器 handlepointerdown
一样,您只能删除 handlepointerdown
,不能在同一个监听器
中删除 dbltapzoom
function dbltapzoom(){
alert("Remove");
}
function handlepointerdown(evt) {
var coord = map.screenToGeo(evt.currentPointer.viewportX,
evt.currentPointer.viewportY);
polygonStroke.setGeometry(coord);
polygonStroke.setVisibility(true);
locationVertices.push(polygonStroke);
map.addObject(polygonStroke);
}
map.addEventListener('pointerdown', handlepointerdown,false);
map.addEventListener('dbltap', function () {
map.removeEventListener('pointerdown',handlepointerdown,false);
});
我正在尝试从地图中删除“addEventListerner”,但它不起作用有我的代码:
function dbltapzoom(){
alert("Remove");
}
map.addEventListener('pointerdown', function (evt) {
var coord = map.screenToGeo(evt.currentPointer.viewportX,
evt.currentPointer.viewportY);
polygonStroke.setGeometry(coord);
polygonStroke.setVisibility(true);
locationVertices.push(polygonStroke);
map.addObject(polygonStroke);
},false);
map.addEventListener('dbltap', function () {
map.removeEventListener('pointerdown',dbltapzoom,false);
});
老实说,我不知道该怎么做。任何帮助和解释我做错了什么都会很好。感谢您的帮助:)
您只能删除同一个注册的侦听器。就像您在 pointerdown
上注册到映射列表器 handlepointerdown
一样,您只能删除 handlepointerdown
,不能在同一个监听器
dbltapzoom
function dbltapzoom(){
alert("Remove");
}
function handlepointerdown(evt) {
var coord = map.screenToGeo(evt.currentPointer.viewportX,
evt.currentPointer.viewportY);
polygonStroke.setGeometry(coord);
polygonStroke.setVisibility(true);
locationVertices.push(polygonStroke);
map.addObject(polygonStroke);
}
map.addEventListener('pointerdown', handlepointerdown,false);
map.addEventListener('dbltap', function () {
map.removeEventListener('pointerdown',handlepointerdown,false);
});