Upon a double click, the API will still fire two single clicks, so
what I do is to use only the single click event and separate single
from double clicks with a setTimeout, like this:
// Global variable
var clckTimeOut = null;
// Only single click listener
GEvent.addListener(map,'click',mapClick);
function mapClick(ol,latlon,olLatlon) {
if (clckTimeOut) {
window.clearTimeout(clckTimeOut);
clckTimeOut = null;
doubleClick(ol,latlon);
}
else {
clckTimeOut = window.setTimeout(function()
{singleClick(ol,latlon,olLatlon)},500);
}
}
function doubleClick(ol,latlon,olLatlon) {
// Process double click
}
function singleClick(ol,latlon,olLatlon) {
window.clearTimeout(clckTimeOut);
clckTimeOut = null;
// Process single click
}
Working example:
http://maps.forum.nu/gm_main.html
--
Marcelo - http://maps.forum.nu
--
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---