How to disable touch detection when google map animation works in android

When I use the method below to perform an animation on a google map, the animation ends if we touch the screen during the animation.

googleMap.animateCamera(
                        CameraUpdateFactory.newCameraPosition(cameraPosition1),400,
                        new CancelableCallback() {

                              @Override
                              public void onFinish() {
                              }

                              @Override
                              public void onCancel() {
                              }
        });

I tried disabling touch detection using the code below

mapFragment.getView().setEnabled(false); 

googleMap.getUiSettings().setAllGesturesEnabled(false);

but the application detects a touch, despite the lines above. How to disable touch?

+5
source share
4 answers

Do not use setEnabled(false)for presentation instead of usingsetClickable(false)

mapFragment.getView().setClickable(false);

That should work.

EDIT

Apparently this is a bug registered here

https://code.google.com/p/gmaps-api-issues/issues/detail?id=5114

, MapFragment.

+3

( ).

, MapFragment, OnTouchListener , true.

, MapFragment, "". "".

+1

:

<FrameLayout
    android:id="@+id/mapFragmentContainerFl"
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:layout_marginEnd="@dimen/screen_horizontal_margin"
    android:layout_marginStart="@dimen/screen_horizontal_margin"
    android:layout_marginTop="12dp"
    app:layout_constraintTop_toBottomOf="@+id/locationDescriptionTv"
    android:background="#10000000">

    <View
        android:id="@+id/mapClickListenerView"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:clickable="true"
        android:focusable="true"
        android:translationZ="12dp"/>

</FrameLayout>

private fun initMapFragment() {
    val mapOptions = GoogleMapOptions().apply {
        zoomControlsEnabled(false)
        zoomGesturesEnabled(false)
        ambientEnabled(false)
        rotateGesturesEnabled(false)
        tiltGesturesEnabled(false)
        scrollGesturesEnabled(false)
        compassEnabled(false)
    }
    val mapFragment = SupportMapFragment.newInstance(mapOptions)
    childFragmentManager.beginTransaction()
            .add(R.id.mapFragmentContainerFl, mapFragment)
            .commit()
    mapFragment.getMapAsync(::onMapReady)
}
0
 mMap.setOnCameraMoveStartedListener(new GoogleMap.OnCameraMoveStartedListener() {
        @Override
        public void onCameraMoveStarted(int reason) {
            mCameraMoveReason = reason;
            if (mCameraMoveReason != GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE)
                mMap.getUiSettings().setAllGesturesEnabled(false);
        }
    });



@Override
public void onCameraIdle() {
    mMap.getUiSettings().setAllGesturesEnabled(true);
    }


  @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
}

mMap.getUiSettings(). setAllGesturesEnabled() / . ,

0
source

All Articles