Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get place name #194

Open
tcqq opened this issue Sep 15, 2018 · 0 comments
Open

How to get place name #194

tcqq opened this issue Sep 15, 2018 · 0 comments

Comments

@tcqq
Copy link

tcqq commented Sep 15, 2018

@mcharmas Now I use the following code to get the place address, but how should I get the place name?

    private fun googleLocation() {
        locationProvider = ReactiveLocationProvider(applicationContext, ReactiveLocationProviderConfiguration
                .builder()
                .setRetryOnConnectionSuspended(true)
                .build())
        val locationRequest = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setNumUpdates(1)
        locationProvider!!.getUpdatedLocation(locationRequest)
                .doOnNext {
                    latitude = it.latitude
                    longitude = it.longitude
                    Timber.d("latitude: $latitude longitude: $longitude")
                }
                .flatMap { location ->
                    locationProvider!!.getReverseGeocodeObservable(location.latitude, location.longitude, 1)
                }
                .map { addresses -> if (!addresses.isEmpty()) addresses[0] else null }
                .map(AddressToStringFunc())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .`as`(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY)))
                .subscribe(DisplayTextOnViewAction(location), ErrorHandler()).isDisposed
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant