google-maps - 如何放大设备的实际位置?
问题描述
我无法放大设备的当前位置,有人可以帮我吗?欢迎任何帮助。
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)
}
解决方案
通常,您可以通过更改相机位置来更改地图的缩放级别。根据此文档:
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
// 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 -相机和视图设置的更多信息,请参阅https://developers.google.com/maps/documentation/android-sdk/views
推荐阅读
- python-3.x - 从其他模块(action_donne 和 action_confirm')创建股票移动 odoo 12 时出错?
- express - 有没有办法在带有 socketIO 的多人 HTML5 画布游戏上显示来自 Node/Express 服务器的私人信息?
- virtual-machine - 使用 qemu-img 将 qcow2 转换为 vdi 时出错
- sql - SQL 掩码列 concat 与静态字符串
- apache-spark - PyCharm - 连接到 oracle DB 时找不到驱动程序错误
- flutter - Flutter:如何确保从异步函数正确初始化变量?
- android - Tmap 和 TWebBrowser 重叠 TMultiview,适用于 Android 和 Windows
- java - 如何在过滤器中添加请求标头并在控制器中获取该标头
- python - 由于分类交叉熵损失,图形断开错误
- vba - Ms Access 表或查询