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

陌路散爱 提交于 2019-12-12 08:13:01

问题


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


回答1:


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.




回答2:


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;
}


来源:https://stackoverflow.com/questions/749887/how-to-use-android-map-to-zoom-with-hand-gesture-iphone-like

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