Android googlemaps V2 - Disable scroll on pan or zoom

后端 未结 3 861
自闭症患者
自闭症患者 2020-12-15 00:13

I would like to disable scroll on Android googlemaps when the user is zooming. In IOS google maps, its kind of easy, just set a parameter: self.settings.allowScrollGesturesD

3条回答
  •  温柔的废话
    2020-12-15 00:38

    This is an old question but I had the same issue. After some googling I found this solution (which I think is the proper one): Have your activity implement onMapReadyCallback and then in your overridden onMapReady set the googleMap.getUiSettings().setScrollGesturesEnabledDuringRotateOrZoom(false); That made the trick for me.

    public class MainActivity extends AppCompatActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks,
            GoogleApiClient.OnConnectionFailedListener{
            GoogleMap gMap;
        }
    
        @Override
        public void onMapReady(GoogleMap googleMap) {
            gMap = googleMap;
            gMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
            gMap.getUiSettings().setZoomControlsEnabled(true);
            gMap.getUiSettings().setZoomGesturesEnabled(true);
            gMap.getUiSettings().setCompassEnabled(false);
            gMap.getUiSettings().setScrollGesturesEnabled(false);
            gMap.getUiSettings().setScrollGesturesEnabledDuringRotateOrZoom(false);
            gMap.setMyLocationEnabled(false);
            gMap.animateCamera(CameraUpdateFactory.zoomTo(8f));
        }
    

提交回复
热议问题