如何知道用户是否更改了缩放比例(Google Maps V3) [英] How to know if the user change zoom (Google Maps V3)
本文介绍了如何知道用户是否更改了缩放比例(Google Maps V3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Google Maps和Angularjs开发一个应用程序.我有这段代码可以控制缩放比例是否更改
I'm developing an app with Google Maps and Angularjs. I have this code to control whether the zoom is changed
google.maps.event.addListener(map, 'zoom_changed', function(){
});
问题是,仅在用户更改缩放时才需要执行此事件.我的代码中还有一个fitBounds()
,它也可以更改缩放比例.
The question is, I need to execute this event only when the user changes the zoom. I have in my code a fitBounds()
that change the zoom as well.
var latlngbounds = new google.maps.LatLngBounds();
for (var i = 0; i < latlng.length; i++) {
latlngbounds.extend(latlng[i]);
}
map.fitBounds(latlngbounds);
是否可以区分用户操作和不区分用户操作?
Is there an option to distinguish between user action and not?
推荐答案
好,我找到了方法
google.maps.event.addListenerOnce(map, 'mousemove', function(){
google.maps.event.addListener(map, 'zoom_changed', function(){
});
});
首先,它会检测鼠标是否移动,然后检测缩放是否改变并且可以正常工作!
First, it detects if the mouse moves and then if the zoom if changed and works properly!
这篇关于如何知道用户是否更改了缩放比例(Google Maps V3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文