Google Map Api v3在地图上拖动活动 [英] Google Map Api v3 drag event on map

查看:131
本文介绍了Google Map Api v3在地图上拖动活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌地图v3 api。我需要检测地图上的拖动事件。无论是在地图上拖动到附近的地理位置或拖动标记。

I am using google map v3 api. I need to detect the drag event on the map. Be it the drag on the map to move to a nearby geographical location or a drag on the marker. I need some javascript function to run when either of the events occur.

推荐答案

Map对象和Marker对象都有 drag events,尽管你可能想要 dragend ,这样当用户完成拖动而不是在用户做某事时拖动。

Both Map objects and Marker objects have drag events, although you probably want dragend so that you can do something when a user is done dragging rather than do something while a user is dragging.

所以你可以这样做:

So you could do something like this:

google.maps.event.addListener(map, 'dragend', function() { alert('map dragged'); } );
google.maps.event.addListener(marker, 'dragend', function() { alert('marker dragged'); } );

这篇关于Google Map Api v3在地图上拖动活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆