Long click event?

1,734 views
Skip to first unread message

Anna PS

unread,
Jun 8, 2011, 1:34:13 PM6/8/11
to google-map...@googlegroups.com
Hi there

I'm building a mobile application that involves routing. I would like to allow users to set markers on a map with a long-click (aka taphold, aka click and hold for >500ms) event.

You can see the interface here: http://cyclestreets.darkgreener.com/route.html

Currently I set markers on the 'dblclick' event: I previously used 'click' but found the usability was poor as it was much too easy to set markers accidentally, just by touching the screen as you moved the phone in your hands. 

Is there a way I could approximate a long-click event in the Google Maps v3 API? Perhaps doing something clever with timers? 

Long-click seems like a very handy event for mobile users, so it would be a great addition to the API. 

many thanks
Anna
Message has been deleted

Esa

unread,
Jun 9, 2011, 7:29:28 PM6/9/11
to Google Maps JavaScript API v3


On Jun 8, 8:34 pm, Anna PS <annapowellsm...@gmail.com> wrote:

> Long-click seems like a very handy event for mobile users

Absolutely. I been doing it with something like:

google.maps.event.addListener(map, 'mousedown', function(){
clearTimeout(map.pressButtonTimer);
map.pressButtonTimer = setTimeout(function(){
doSomethingUseful();
}, 500);
});

clearTimeout() is essential. Note that you can often see 'if()'
statement with clearTimeout but that is not needed by Ecma standard.

map.pressButtonTimer is a variable name, not any API property.

Anna PS

unread,
Jun 20, 2011, 6:07:01 AM6/20/11
to Google Maps JavaScript API v3
Thanks, but this doesn't work for me: it fires on single clicks and
simply waits for 500ms before firing doSomethingUseful.

I really need a 'taphold' event: i.e. only fires if the user clicks
the map *and deliberately holds* it for 500ms.

That way, you can be certain the user hasn't just touched the map
while moving the phone between hands - they really mean to fire the
event.

I think this would be a really useful event for Google Maps.

Any ideas, anyone?

On Jun 10, 12:29 am, Esa <esa.ilm...@gmail.com> wrote:
> On Jun 8, 8:34 pm, Anna PS <annapowellsm...@gmail.com> wrote:
>
> >Long-clickseems like a very handy event for mobile users

Chris Broadfoot

unread,
Jun 20, 2011, 6:47:11 AM6/20/11
to google-map...@googlegroups.com
Something like this?

Did you try to implement this? It wasn't terribly difficult.

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Reply all
Reply to author
Forward
0 new messages