reverseGeocode

Translates geographic coordinates (latitude and longitude) into a human-readable address.

The reverse geocoder attempts to describe the location using labels like "Amsterdam, Netherlands" for an area or "Oosterdoksstraat 114, 1011 DK Amsterdam, Netherlands" for an address.

Note: This is a synchronous operation and it must not be executed on the main thread.

Usage Example:

// Create a reverse geocoder instance.
val reverseGeocoder = OnlineReverseGeocoder.create(
applicationContext,
"your_api_key_here",
customApiUrl = URL("https://api.proxy.com/search/10"),
geopoliticalView = "IND"
)

val options = ReverseGeocoderOptions(position = GeoPoint(52.391174, 4.910375))

val result = reverseGeocoder.reverseGeocode(options)

if (result.isSuccess()) {
val response = result.value()
// Process the reverse geocoding response.
Log.d(response)
} else {
val failure = result.failure()
// Handle the reverse geocoding failure.
Log.d(failure.message)
}

Return

A Result containing a ReverseGeocoderResponse with matched addresses if successful, or a SearchFailure if the operation fails.

Parameters

options

Defines the input and filters of the request, such as the location to be reverse geocoded and the desired result language.


Translates geographic coordinates (latitude and longitude) into a human-readable address.

The reverse geocoder aims to describe the location using labels like "Amsterdam, Netherlands" for an area or "Oosterdoksstraat 114, 1011 DK Amsterdam, Netherlands" for an address.

This is an asynchronous operation; the result is provided through callback.

Note: The callback is executed on the main thread.

Usage example:

// Create a reverse geocoder instance.
val reverseGeocoder = OnlineReverseGeocoder.create(
applicationContext,
"your_api_key_here",
customApiUrl = URL("https://api.proxy.com/search/10"),
geopoliticalView = "IND"
)

val options = ReverseGeocoderOptions(position = GeoPoint(52.391174, 4.910375))

val callback = object : ReverseGeocoderCallback {
override fun onSuccess(response: ReverseGeocoderResponse) {
// Process the reverse geocoding response.
Log.d(response)
}

override fun onFailure(failure: SearchFailure) {
// Handle the reverse geocoding failure.
Log.d(failure.message)
}
}

val cancellable = reverseGeocoder.reverseGeocode(options, callback)

// You can cancel the operation if needed:
cancellable.cancel()

Return

A Result containing a ReverseGeocoderResponse with matched addresses if successful, or a SearchFailure if the operation fails.

Parameters

options

Defines the input and filters of the request, such as the location to be reverse geocoded and the desired result language.

callback

A ReverseGeocoderCallback invoked asynchronously when the search operation is completed, either successfully or with an error. The callback executes on the main thread.