views:

26

answers:

1

Hi all,

I'm creating a web app for mobile phones where if they longpress a certain part of the map, something happens. Unfortunately I can't use a window.setTimeout(..) with a mousedown/mouseup combination because the Maps API doesn't contain those events as it would disrupt the drag events. Is there another way to do this? There has to be a way because the Maps webapp on mobile pops up the same menu when you longpress as right-click on Google maps for computers - just don't know how! Please let me know!!

Thanks in advance!

A: 

Excellent question. After much digging, I found the following page on touch and gesture events for Android and iPhone. Hopefully this list will be of some use to you:

http://backtothecode.blogspot.com/2009/10/javascript-touch-and-gesture-events.html

To elaborate, you're probably going to want to handle the touchstart and touchend events, perhaps keeping track of the position of the "cursor" at each to determine if it was a drag or simply a press. Good luck, and I don't blame you if you don't consider this a definitive answer. :P

Faisal
Thanks so much! I'll give that a shot tomorrow and I'll let you know!
MapWeb
No problem. :) I'm curious to hear how it goes.
Faisal
Unfortunately this didn't work :( ..I'll keep searching and hopefully I'll find something. Thanks anyways though!
MapWeb