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:
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');
});
}
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:
google.maps.event.addListener(circle, 'click', function(event) {
if (event.alreadyCalled_) {
alert('circle clicked again');
}
else {
alert('circle clicked first time');
event.alreadyCalled_ = true;
}
});
The click is still triggered twice but you can detect it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With