How to handle onTouch event for map in Google Map API v2?

后端 未结 2 1793
误落风尘
误落风尘 2020-11-27 06:17

GoogleMap by default doesn\'t provide event for map drag start and drag stop. I have already reported that problem here.

I want to make custom

2条回答
  •  孤城傲影
    2020-11-27 06:50

    There is a simpler way to do this, handle your cases on onCameraMoveStarted listener like this

    Below the code snippet

    @Override
    public void onCameraMoveStarted(int reason) {
        if (reason == OnCameraMoveStartedListener.REASON_GESTURE) {
            Toast.makeText(this, "The user gestured on the map.",
                           Toast.LENGTH_SHORT).show();
        } else if (reason == OnCameraMoveStartedListener
                                .REASON_API_ANIMATION) {
            Toast.makeText(this, "The user tapped something on the map.",
                           Toast.LENGTH_SHORT).show();
        } else if (reason == OnCameraMoveStartedListener
                                .REASON_DEVELOPER_ANIMATION) {
            Toast.makeText(this, "The app moved the camera.",
                           Toast.LENGTH_SHORT).show();
        }
    }
    

提交回复
热议问题