google.maps.event.addListener(map, "idle", function() - 是否可以指定空闲时间?

发布于 2025-01-04 20:39:12 字数 112 浏览 4 评论 0 原文

google.maps.event.addListener(map, "idle", function() 

是否可以指定空闲时间?

谢谢人族

google.maps.event.addListener(map, "idle", function() 

Is it Possible to specify The Idle Time ?

Thanks Terran

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦亿 2025-01-11 20:39:12

不,不幸的是这个功能不存在。实现此目的的最佳方法是使用 window.setTimeout 的组合和window.clearTimeout

我建议像这样(未经测试):

google.maps.event.addListener(map, 'idle', function() {
   var idleTimeout = window.setTimeout(onIdle, timeout);
   google.maps.event.addListenerOnce(map, 'bounds_changed', function() {
     window.clearTimeout(idleTimeout);
   });
});

注意使用 addListenerOnce,它仅在事件第一次发生时触发。

No, unfortunately this feature doesn't exist. The best way to achieve this is to use a combination of window.setTimeout and window.clearTimeout.

I'd suggest something like this (untested):

google.maps.event.addListener(map, 'idle', function() {
   var idleTimeout = window.setTimeout(onIdle, timeout);
   google.maps.event.addListenerOnce(map, 'bounds_changed', function() {
     window.clearTimeout(idleTimeout);
   });
});

Note the use of addListenerOnce, which fires only the first time the event occurs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文