Thursday, June 10, 2010

Re: [android-developers] Google Maps API: Catching zoom and panning events

On 6/9/2010 7:13 PM, Steve Howard wrote:
> On Tue, Jun 8, 2010 at 9:03 PM, Raymond Rodgers
> <raymond@badlucksoft.com <mailto:raymond@badlucksoft.com>> wrote:
>
>
>
> On Tue, Jun 8, 2010 at 7:14 PM, Steve Howard <steveh@android.com
> <mailto:steveh@android.com>> wrote:
>
> A simple solution is to add an Overlay, override the draw()
> method, and not actually do any drawing, but simply use the
> method as a hook to know anytime the map has potentially moved
> or zoomed. The problem is, this will get called more often
> than necessary, so you'll need some custom logic to decide
> when the viewport has changed "enough" for you to make a new
> query. This shouldn't be too difficult however -- you can
> track the current center and zoom in your Overlay subclass --
> and you'd probably need some kind of logic like this anyway.
>
> Let me know how that works for you, or if it works at all.
>
> Steve
>
>
> Thanks Steve, I eventually came to give that very method a try,
> although I haven't yet decided on how to avoid the excessive
> updating. I may try to find out when the user's fingers are no
> longer on the touch screen or when the trackball (if present) is
> no longer moved.
>
>
> Yeah, you do have to do some work here, which is unfortunate. There
> are several options, you may already be aware of them. One is to use
> Overlay.onTouchEvent() to detect ACTION_UP events, which could help
> detect when touch gestures have finished. Another is to use a timeout
> mechanism in draw() itself. On each draw() call, you can have a
> Handler to send a message at a specified time in the near future,
> after canceling any other such previously requested messages. When
> you get the message, you know the user's been idle for that short
> period of time. android.view.GestureDetector uses this approach for
> long press detection, among other things -- check out lines 456-7,
> http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/GestureDetector.java.
Thanks for the tip, I was thinking about the touch interface route so
I'll look in that direction.
Raymond

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment