I'm making a google map (v3) mashup where there is a map listener for a click event.
google.maps.event.addListener(map, 'click', function(event) {addMarker(event)});
This click event on the map results in creating a new marker. However, I am also building a OverlayView (in the floatPane of the google map) with a jQuery button upon clicking a marker.
markerDialogOverlay.prototype.onAdd = function()
{
var divToAdd = document.createElement('div');
divToAdd.id = 'markerHelper';
divToAdd.title = 'Edit Marker';
this.div = divToAdd;
var panes = this.getPanes();
panes.floatPane.appendChild(this.div);
this.jqdiv = $('#markerHelper');
this.jqdiv.empty();
}
markerDialogOverlay.prototype.draw = function()
{
overlayProjection = this.getProjection();
var posxy = overlayProjection.fromLatLngToDivPixel(this.marker.getPosition());
this.jqdiv.css({ 'z-index': '1',
'left': posxy.x + 'px',
'top': posxy.y + 'px',
'position' : 'absolute'});
this.jqdiv.append($('<button id="deleteMarker">Delete</button>').button().click(function(){deleteLocation(this.marker)}).hide().fadeIn('slow'));
}
Upon clicking the jQuery button, both the jQuery button click event and the google map click event are fired, but I want just the jQuery button click to be fired.
I still want to enable the map click event just not where the OverlayView div is located. Any ideas on how to work around this?
I searched a little harder in the google maps forum and found this topic: http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/ef6e8e2942421bab/ff3739505eb833df?pli=1. Canceling the event propagation to the map solved the issue.
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