问题描述
我正在关注本页面中的MVCObject绑定示例:
我想要改变圆的颜色并在用户点击圆时切换标记的可见性,所以我将侦听器添加到RadiusWidget构造函数中,如下所示: 我的问题是click事件正在触发TWICE。有谁知道为什么? 我有类似的问题。它可能是地图API v3中的错误吗?我没有答案,只是一个解决方法: 点击仍会触发两次,但您可以检测到。 I am following the MVCObject binding example from this page: http://code.google.com/apis/maps/articles/mvcfun.html I want to change the color of the circle and toggle the visibility of the markers when the user clicks on the circle, so I add the listener into the RadiusWidget constructor as follows: My problem is that the click event is firing TWICE. Does anyone know why? I had a similar problem. Could it be a bug in maps API v3? I do not have an answer but a workaround: The click is still triggered twice but you can detect it. 这篇关于Google Maps Api V3:单击事件触发两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
<$ p $ (){
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');
});
}
google.maps.event.addListener(circle,'click',function(事件){
if(event.alreadyCalled_){
alert('circle clicked');
}
else {
alert('首次点击的圆圈' );
event.alreadyCalled_ = true;
}
});
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');
});
}
google.maps.event.addListener(circle, 'click', function(event) {
if (event.alreadyCalled_) {
alert('circle clicked again');
}
else {
alert('circle clicked first time');
event.alreadyCalled_ = true;
}
});