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

Deadly 提交于 2019-12-03 15:58:17

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.

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!