Disable moving around in mapview

前端 未结 9 797
执念已碎
执念已碎 2020-12-16 11:06

Is it possible to disable moving inside the google map?

9条回答
  •  别那么骄傲
    2020-12-16 11:39

    We can stop user interactions with MapView or SupportMapFragment using GoogleMapOptions

    override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            val mapOptions = GoogleMapOptions()
            mapOptions.rotateGesturesEnabled(false)
            mapOptions.zoomGesturesEnabled(false)
            mapOptions.tiltGesturesEnabled(false)
            mapOptions.scrollGesturesEnabled(false)
    
            // Map View
            val mapView = MapView(context, mapOptions)
            mapView.onCreate(savedInstanceState)
    
            // Or
            val mapView = MapView(context
            mapView.getMapAsync { googleMap ->
               googleMap.uiSettings.setAllGesturesEnabled(false) 
            }
    
           // Or Map Fragment
           val mapFragment = SupportMapFragment.newInstance(mapOptions)
    }
    

提交回复
热议问题