MapView 监听事件

手势监听事件
  • 设置地图单击事件监听
 mMap.setOnSingleTapListener(new OnSingleTapListener() {
            @Override
            public void onSingleTap(float v, float v1) {
                //v,v1视窗横纵坐标(屏幕坐标)
            }
        });
  • 设置地图长按事件监听
 mMap.setOnLongPressListener(new OnLongPressListener() {
            @Override
            public boolean onLongPress(float v, float v1) {
                //v,v1视窗横纵坐标(屏幕坐标)
                return false;
            }
        });
  • 设置地图平移事件监听
mMap.setOnPanListener(new OnPanListener() {
            @Override
            public void prePointerMove(float v, float v1, float v2, float v3) {
                //v,v1-v2,v3 (开始屏幕坐标-结束屏幕坐标)
            }

            @Override
            public void postPointerMove(float v, float v1, float v2, float v3) {

            }

            @Override
            public void prePointerUp(float v, float v1, float v2, float v3) {

            }

            @Override
            public void postPointerUp(float v, float v1, float v2, float v3) {

            }
        });
  • 地图捏夹事件监听
 mMap.setOnPinchListener(new OnPinchListener() {
            @Override
            public void prePointersMove(float v, float v1, float v2, float v3, double v4) {

            }

            @Override
            public void postPointersMove(float v, float v1, float v2, float v3, double v4) {

            }

            @Override
            public void prePointersDown(float v, float v1, float v2, float v3, double v4) {

            }

            @Override
            public void postPointersDown(float v, float v1, float v2, float v3, double v4) {

            }

            @Override
            public void prePointersUp(float v, float v1, float v2, float v3, double v4) {

            }

            @Override
            public void postPointersUp(float v, float v1, float v2, float v3, double v4) {

            }
        });
  • 地图缩放事件监听
mMap.setOnZoomListener(new OnZoomListener() {
            @Override
            public void preAction(float v, float v1, double v2) {
                
            }

            @Override
            public void postAction(float v, float v1, double v2) {

            }
        });
  • 地图状态改变事件监听
 mMap.setOnStatusChangedListener(new OnStatusChangedListener() {
            @Override
            public void onStatusChanged(Object o, STATUS status) {
                if (status.equals(STATUS.INITIALIZATION_FAILED)) {
                }

                if (status.equals(STATUS.INITIALIZED)) {
//                    AlertMsg("mapView的状态改变时:%s", "初始化完成");
                }
                if (status.equals(STATUS.LAYER_LOADED)) {
//                    AlertMsg("mapView的状态改变时:%s", "图层加载完成");
                }
                if (status.equals(STATUS.LAYER_LOADING_FAILED)) {
//                    AlertMsg("mapView的状态改变时:%s", "图层加载失败");
                }
            }
        });

你可能感兴趣的:(MapView 监听事件)