Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable touch detection while Google Map animation is running in android

When I use the method below to execute an animation on google map, the animation ends if we touch the screen while animation is executing.

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

                              @Override
                              public void onFinish() {
                              }

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

I have tried disabling the touch detection using the code below

mapFragment.getView().setEnabled(false); 

googleMap.getUiSettings().setAllGesturesEnabled(false);

but the application detects touch despite the above lines. How do you correctly disable touch?

like image 838
1'hafs Avatar asked Sep 29 '22 23:09

1'hafs


1 Answers

Don't use setEnabled(false) for the view instead use setClickable(false)

mapFragment.getView().setClickable(false);

This should work.

EDIT

Apparently this is bug filed here

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

as a work around you can deploy a transparent layer which will receive touch events instead of MapFragment .

like image 148
Sharp Edge Avatar answered Oct 13 '22 00:10

Sharp Edge