Android Google Maps: disable dragging in MapFragme

2019-02-04 04:22发布

Can I disable drag functionality when the user tries to drag the map with his fingers without disturbing the Zoom in and Zoom out?

Any one please suggest an idea of doing this! Thanks for your Precious help!!

4条回答
Viruses.
2楼-- · 2019-02-04 04:33

You can disable dragging in MapFragment using:

googleMap.getUiSettings().setScrollGesturesEnabled(false);
查看更多
叼着烟拽天下
3楼-- · 2019-02-04 04:41

I think here's what you're looking for:

Inside Google Maps Android v2

Scroll (pan) gestures

A user can scroll (pan) around the map by dragging the map with their finger. You can disable scrolling by calling UiSettings.setScrollGesturesEnabled(boolean).

查看更多
何必那么认真
4楼-- · 2019-02-04 04:42

for disable dragging in MapFragment this code :

googleMap.getUiSettings().setScrollGesturesEnabled(false);

works as @tomrozb said. but it dosn't disable map zoom by touch on map. for that use this code beside above code:

googleMap.getUiSettings().setZoomGesturesEnabled(false);
查看更多
一夜七次
5楼-- · 2019-02-04 04:51

you can use isScrollGesturesEnabled for map

java:

googleMap.getUiSettings().setZoomGesturesEnabled(false);

kotlin

googleMap?.uiSettings?.isScrollGesturesEnabled = false
查看更多
登录 后发表回答