views:

1833

answers:

2

How do you use the Android API to zoom in and out maps with the 2 finger gestures like iPhone?

A: 

Android doesn't currently officially support multitouch. There's been some work by various people (Your google for 'android multitouch' is as good as mine), but nothing in the official android distro or APIs yet.

A relevant blog post just showed up in my feedreader with more particulars.

UPDATED: As of Android API Level 5 (aka Android 2.0), Android does have a multi-touch API. Support for it is, of course, browser-specific.

pjz
Actually multitouch is available in the current SDK.
CaseyB
+6  A: 

You need to override the MapActivity's OnTouchEvent() with something like this:

@Override
public boolean onTouchEvent(final MotionEvent event)
{
    if(event.getPointerCount() > 1)
    {
        int x1 = event.getX(0);
        int y1 = event.getY(0);
        int x2 = event.getX(1);
        int y2 = event.getY(1);

        // Get the distance and see how it compares to the previous
        // distance between these two pointers
    }
    return true;
}
CaseyB