Skip to content

How to get place name #194

@tcqq

Description

@tcqq

@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
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions