Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Android Map to zoom with hand gesture (iphone like)

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

like image 424
Tam N. Avatar asked Apr 15 '09 00:04

Tam N.


1 Answers

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;
}
like image 104
CaseyB Avatar answered Oct 05 '22 05:10

CaseyB