Ridcully
Ridcully

Reputation: 23665

Catch double tap events on new Google Maps Android API v2

I have an app with a ViewSwitcher that has a MapView (v1) and another View and using a GestureDetector I can detect double taps and switch between the 2 views.

Now I'm trying to switch the app to the new Google Maps Android API V2 and I have the problem that the GestureDetector set on the MapView no longer reacts to double taps, instead the map is zooming in. Does anyone know how to change that behaviour?

I'm working with the raw MapView class, not the Map fragment.

Upvotes: 0

Views: 4749

Answers (2)

Ridcully
Ridcully

Reputation: 23665

Okay, I found a way now. I have to create a sub class of MapView (which is actually a ViewGroup) and implement interceptTouchEvent() there to detect and catch double taps.

How this is implemented in detail is explained here: Double Tap -> Zoom on Android MapView?

Upvotes: 2

Tamás Cseh
Tamás Cseh

Reputation: 3090

As far as I know (and according to: http://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.html), you can set to the GoogleMap object (and also to the MapView) click and long click listener. So I think you can't set a double click listener.

But you can try this:

GoogleMap map=mapView.getMap();
map.getUiSettings().setZoomGesturesEnabled(false);

And maybe it will react to your GestureDetector.

Upvotes: 1

Related Questions