googleMap如何设置OnTouchListener?

时间:2016-02-15 13:39:30

标签: android google-maps-android-api-2 ontouchlistener

googleMap如何设置OnTouchListener? 我正在尝试此代码,但错误:

GoogleMap googleMap = …;

googleMap.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if(event.getAction() == MotionEvent.ACTION_UP){
            Log.e("MOVE: ","moving");
            return true;
        }
        return false;
    }
});

1 个答案:

答案 0 :(得分:0)

使用GoogleMap.OnMapClickListener

googleMap.setOnMapClickListener(new OnMapClickListener() {

    @Override
    public void onMapClick(LatLng arg0) {
        Log.i(TAG, arg0.latitude + "-" + arg0.longitude);
    }

});

修改

使用GoogleMap.OnCameraChangeListener

googleMap.setOnCameraChangeListener(new OnCameraChangeListener() {

    @Override
    public void onCameraChange(CameraPosition cameraPosition) {
        LatLng latLng = cameraPosition.target;
        // do your thing with "latLng"
    }

});