问题
Android and GoogleMaps: Can I disable the mapView dragging without disable the pinch to zoom function? Thx for answer
回答1:
Use GestureDetector
and SimpleOnGestureListener
, use onFling()
to detect the distance between the path user did with his finger from the first touch till the release with .getX()
and getY()
from each MotionEvent
and do nothing for x > SOMEMAXVALUE
and y > SOMEMAXVALUE
. I hope you'll find your way.
回答2:
I suggest overridding dispatchDraw()
in MapView
class and check if the center is the one you want. Use getController().setCenter(...)
to recenter the map.
Just an alternative to what other people suggested.
来源:https://stackoverflow.com/questions/6802796/android-and-googlemaps-disable-the-mapview-dragging