Wednesday, April 11, 2012

Google Map Bug, Dragend Event also trigger Click Event in IE

I have found that dragend event in Google Map also trigger the click event in IE. It is OK in Firefox and Chrome. Open IE/FF/Chrome console and see the result of this fiddle. Any workaround will be appreciated.


http://jsfiddle.net/ABqMH/8/


Bug Submitted at here.


Answer:

here is a quick workaround
var map; var elevator; var dragged = false; var myOptions = { 
    zoom: 6, 
    center: new google.maps.LatLng(46.87916, -3.32910), 
    mapTypeId: 'terrain' }; 
map = new google.maps.Map($('#map')[0], myOptions); var marker = new google.maps.Marker({ 
            map: map, 
    position: new google.maps.LatLng(46.87916, -3.32910), 
    draggable: true }); 
google.maps.event.addListener(marker, 'dragend', function () { 
    console.log('dragend'); 
    dragged = true; 
    setTimeout(function(){ dragged = false; }, 200); 
        }); 
google.maps.event.addListener(map, 'click', function (evt) { if (dragged) return; 
console.log('click') }); 

No comments:

Post a Comment