本文介绍了在地图上调用fitBounds函数时,请勿触发'zoom_changed'事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法防止由于fitBounds()引发的zoom_change事件被触发?



我有一个问题,我需要做一个搜索客户端上的服务器时,如果缩放更改为映射,但每次调用fitBounds()时都会导致zoom_change触发,导致客户端在服务器上执行另一次搜索。我只对用户完成的zoom_change感兴趣,而不是以编程方式使用fitBounds。

解决方案

当您在程序中执行fitBounds时,设置一个全球旗帜。当zoom_changed事件触发时,如果标志被设置,清除它,否则将请求发送到服务器。

Is there a way to prevent the zoom_change event from being triggered if it occurs due to fitBounds() ?

I am having an issue where I need to do a search on the server from client when there is a zoom change to map but every time I call fitBounds() it causes zoom_change to trigger which causes the client to do another search on the server. I am only interested in zoom_change done by users and not programmatically using fitBounds.

解决方案

When you do a fitBounds in your program, set a global flag. When the zoom_changed event fires, if the flag is set, clear it, otherwise send your request off to the server.

这篇关于在地图上调用fitBounds函数时,请勿触发'zoom_changed'事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:37