获取 google 地图准确位置
Get google map accurate location
我有以下代码 return 用户当前位置,但位置不准确
lateinit var mFusedLocationClient: FusedLocationProviderClient
override fun onCreateView(...) {....}
@SuppressLint("MissingPermission")
private fun getLastLocation() {
mFusedLocationClient.lastLocation
.addOnCompleteListener(requireActivity()) { task ->
if (task.isSuccessful && task.result != null) {
mLastLocation = task.result
mMap.isMyLocationEnabled = true
val driverLatLng = LatLng(mLastLocation.latitude, mLastLocation.longitude)
markerOptions.position(driverLatLng).title("Your location").icon(
BitmapDescriptorFactory.fromBitmap(
driverIcon()
)
)
mMap.addMarker(markerOptions)
} else {
Log.w("location", "getLastLocation:exception", task.exception)
}
}
}
问题
- 如何使当前位置更准确
- 如何让蓝色圆圈变小,覆盖当前定位针(标记)周围?
我有以下代码 return 用户当前位置,但位置不准确
lateinit var mFusedLocationClient: FusedLocationProviderClient
override fun onCreateView(...) {....}
@SuppressLint("MissingPermission")
private fun getLastLocation() {
mFusedLocationClient.lastLocation
.addOnCompleteListener(requireActivity()) { task ->
if (task.isSuccessful && task.result != null) {
mLastLocation = task.result
mMap.isMyLocationEnabled = true
val driverLatLng = LatLng(mLastLocation.latitude, mLastLocation.longitude)
markerOptions.position(driverLatLng).title("Your location").icon(
BitmapDescriptorFactory.fromBitmap(
driverIcon()
)
)
mMap.addMarker(markerOptions)
} else {
Log.w("location", "getLastLocation:exception", task.exception)
}
}
}
问题
- 如何使当前位置更准确
- 如何让蓝色圆圈变小,覆盖当前定位针(标记)周围?