【问题标题】:how to execute google maps event "bounds_changed" only once如何只执行一次谷歌地图事件“bounds_changed”
【发布时间】:2015-08-16 14:02:11
【问题描述】:

如何告诉 google 地图事件“bounds_change”仅在地图最初加载时起作用,而不是在用户更改后起作用?

【问题讨论】:

  • bounds_change 旨在处理可能在应用程序生命周期内多次触发的视口更改。那么为什么要使用这个事件来处理加载的事件呢?
  • 我有两种类型的地图加载。第一次加载调用特定函数,而稍后(由用户)的移动调用不同的函数。我正在尝试使用 get_bounds() 函数,但地图需要先完成边界。所以,我需要在启动时放入一个监听器来执行第一个函数。

标签: javascript google-maps google-maps-api-3


【解决方案1】:

from the documentation

addListenerOnce(instance:Object, eventName:string, handler:function(?))
返回值:MapsEventListener 与 addListener 类似,但处理程序在处理第一个事件后会自行删除。

google.maps.event.addListenerOnce(map,'bounds_changed', function() {});

【讨论】:

    猜你喜欢
    • 2011-09-17
    • 1970-01-01
    • 2022-01-07
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 2014-09-17
    • 1970-01-01
    相关资源
    最近更新 更多