AlexT Asked:2020-02-13 19:05:15 +0000 UTC2020-02-13 19:05:15 +0000 UTC 2020-02-13 19:05:15 +0000 UTC 如何在yandex.mapkit中确定用户的位置 772 这是整个问题... яндекс-карты 1 个回答 Voted Best Answer neverd1m 2020-02-14T22:04:55Z2020-02-14T22:04:55Z 这需要 LocationManager ( https://tech.yandex.ru/maps/doc/mapkit/3.x/concepts/android/mapkit/ref/com/yandex/mapkit/location/LocationManager-docpage/ ) + LocationListener的组合(https://tech.yandex.ru/maps/doc/mapkit/3.x/concepts/android/mapkit/ref/com/yandex/mapkit/location/LocationListener-docpage/)。我们需要请求一个位置更新,当经理调用监听器时,查看 getLastKnownLocation() 。例如,对于 kotlin: locationManager = MapKitFactory.getInstance().createLocationManager() locationManager!!.requestSingleUpdate(object : LocationListener { override fun onLocationStatusUpdated(p0: LocationStatus?) { showMessage(p0?.toString() ?: "No status") } override fun onLocationUpdated(p0: Location?) { showMessage( "lat=${p0?.position?.latitude ?: ""} " + "lon=${p0?.position?.longitude ?: ""}" ) } })
这需要 LocationManager ( https://tech.yandex.ru/maps/doc/mapkit/3.x/concepts/android/mapkit/ref/com/yandex/mapkit/location/LocationManager-docpage/ ) + LocationListener的组合(https://tech.yandex.ru/maps/doc/mapkit/3.x/concepts/android/mapkit/ref/com/yandex/mapkit/location/LocationListener-docpage/)。我们需要请求一个位置更新,当经理调用监听器时,查看 getLastKnownLocation() 。例如,对于 kotlin: