gpt4 book ai didi

javascript - 删除标记监听器

转载 作者:数据小太阳 更新时间:2023-10-29 06:08:54 24 4
gpt4 key购买 nike

这次有点简单的问题(解释一下):

我有一组标记,因此我配备了事件监听器:

for (i in markersArray) {
google.maps.event.addListener(markersArray[i], 'click', function() {
//stuff it does
google.maps.event.removeListener(?????) //remove self... but HOW?!
});}

正如我在评论中提到的,我只是希望监听器在被点击后被移除。

问题是我不知道监听器的句柄是什么。

最佳答案

您可以使用“addListenerOnce”。然后您甚至不必费心删除监听器。

addListenerOnce(instance:Object,eventName:string, handler:Function)

Like event.AddListener, but the handlerremoves itself after handling thefirst event.

关于javascript - 删除标记监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3290117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com