我无法放大设备的当前位置,有人可以帮我吗?
欢迎任何帮助。
override fun onMapReady(googleMap: GoogleMap) {
Log.i("MAP READY", "READY")
val position = if (currentLocation != null) LatLng(currentLocation!!.latitude, currentLocation!!.longitude) else null
this.map = googleMap
getFineLocationPermission()
this.map!!.setOnMarkerClickListener(this)
this.map!!.uiSettings.isRotateGesturesEnabled = true
this.map!!.uiSettings.isZoomGesturesEnabled = true
this.map!!.setOnInfoWindowClickListener(this)
this.map!!.setOnMapLongClickListener(this)
}
最佳答案
通常,您可以通过更改 map 的相机位置来更改 map 的缩放级别。根据此documentation:
To change the position of the camera, you must specify where you want to move the camera, using a CameraUpdate. The Maps API allows you to create many different types of CameraUpdate using CameraUpdateFactory.
由于您没有提供完整的代码,因此让我在下面插入示例:
//where zoomLevel is your preferred zoom level
mMap.moveCamera(CameraUpdateFactory.zoomTo(zoomLevel))
addMarker()
函数下方,可以添加以下行以在City
级别缩放 map :// zoomLevel is set at 10 for a City-level view
val zoomLevel = 10
// latLng contains the coordinates where the marker is added
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,zoomLevel))
有趣的提示:如果您使用
animateCamera()
而不是moveCamera()
有关Android版Maps SDK的更多信息-“相机和 View ”设置,请参阅https://developers.google.com/maps/documentation/android-sdk/views
关于google-maps - 如何放大设备的实际位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58066884/