Catch double tap events on new Google Maps Android API v2

喜欢而已 提交于 2019-12-13 06:44:08

问题


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.


回答1:


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?




回答2:


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.



来源:https://stackoverflow.com/questions/14195858/catch-double-tap-events-on-new-google-maps-android-api-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!