Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable double left click on google map

May I know how can I disable double click on google map so that the info window will not close when I double click on google map? Can it be done through google map api?

like image 805
davidlee Avatar asked Jul 06 '10 13:07

davidlee


2 Answers

You can disable double-click zoom on Google Maps by setting the following google.maps.MapOptions object property:

disableDoubleClickZoom: true

Sample code:

var mapOptions = {
    scrollwheel: false,
    disableDoubleClickZoom: true, // <---
    panControl: false,
    streetViewControl: false,
    center: defaultMapCenter
};
like image 153
Jatin Dhoot Avatar answered Nov 06 '22 16:11

Jatin Dhoot


You can take advantage of, dblclick fires if it is a double click, and single click fires in such occations only once.

runIfNotDblClick = function(fun){
    if(singleClick){
        whateverurfunctionis();
    }
};

clearSingleClick = function(fun){
    singleClick = false;
};

singleClick = false;

google.maps.event.addListener(map, 'click', function(event) {// duh! :-( google map zoom on double click!
    singleClick = true;
    setTimeout("runIfNotDblClick()", 500);
});

google.maps.event.addListener(map, 'dblclick', function(event) {// duh! :-( google map zoom on double click!
     clearSingleClick();
});

See http://www.ilikeplaces.com

like image 41
Ravindranath Akila Avatar answered Nov 06 '22 16:11

Ravindranath Akila