Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ran across this post when looking for the same answer. I couldn't find one so I am adding my solution for posterity.</p> <p>The following is a self installing class which executes double and single clicks regardless of whether or not an overlay is present on the maps.</p> <pre><code>map_click._single(function(event){ console.log(event); }); </code></pre> <p>Is equivalent to:</p> <pre><code>google.maps.event.addListener(map, 'click', function(event) { console.log(event); }); </code></pre> <p>And for double clicks...</p> <pre><code>map_click._double(function(event){ console.log(event); }); </code></pre> <p>Is equivalent to:</p> <pre><code>google.maps.event.addListener(map, 'dblclick', function(event) { console.log(event); }); </code></pre> <p>If you want to set the double click delay you can edit it like:</p> <pre><code>map_click.delay = 300; </code></pre> <p>The default is 300ms which is what I found works best. You could effectively remove double click events by setting <code>map_click.delay</code> to 0. </p> <p>FInally the function:</p> <pre><code>window.map_click = { i : 0 ,_single : function(fn){ if(typeof(fn) != 'function') return; this.singles = this.singles || []; this.singles.push(fn); } ,_double : function(fn){ if(typeof(fn) != 'function') return; this.doubles = this.doubles || []; this.doubles.push(fn); } ,delay : 300 ,_ : (function(){ google.maps.event.addListener(map, 'dblclick', function(event) { if(map_click.timeout) clearTimeout(map_click.timeout); map_click.i = 0; for(_ in map_click.doubles) map_click.doubles[_](event); }); google.maps.event.addListener(map, 'click', function(event) { map_click.i++; map_click._event = event; if(map_click.timeout) clearTimeout(map_click.timeout); if(!(map_click.i%2)){ map_click.i = 0; for(_ in map_click.doubles) map_click.doubles[_](event); }else{ map_click.timeout = setTimeout(function(){ map_click.i = 0; for(_ in map_click.singles) map_click.singles[_](map_click._event); }, map_click.delay); } }); })() }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload