【发布时间】:2011-09-23 07:49:38
【问题描述】:
我正在关注此页面中的 MVCObject 绑定示例:
http://code.google.com/apis/maps/articles/mvcfun.html
我想在用户点击圆圈时改变圆圈的颜色并切换标记的可见性,所以我将监听器添加到RadiusWidget构造函数中,如下所示:
function RadiusWidget() {
var circle = new google.maps.Circle({
strokeWeight: 2
});
this.set('distance', 50);
this.bindTo('bounds', circle);
circle.bindTo('center', this);
circle.bindTo('map', this);
circle.bindTo('radius', this);
this.addSizer_();
google.maps.event.addListener(circle, 'click', function()
{
alert('circle clicked');
});
}
我的问题是点击事件触发了两次。有谁知道为什么?
【问题讨论】:
-
会不会是事件先被
map本身拦截,然后也传递给circle对象呢 -
有没有办法检查监听函数是从哪里调用的?
标签: javascript google-maps-api-3 dom-events