reverseGeocode
open override fun reverseGeocode(options: ReverseGeocoderOptions): Result<ReverseGeocoderResponse, SearchFailure>
Performs reverse geocoding using the provided ReverseGeocoderOptions object.
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 = HybridReverseGeocoder.create(
applicationContext,
"your_tomtom_api_key_here",
ndsStore,
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)
}
Content copied to clipboard
Return
The result of the reverse geocoding operation.
Parameters
options
The object containing data for the Reverse Geocoding call.
open override fun reverseGeocode(options: ReverseGeocoderOptions, callback: ReverseGeocoderCallback): Cancellable
Performs reverse geocoding using the provided ReverseGeocoderOptions object. 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 = HybridReverseGeocoder.create(
applicationContext,
"your_tomtom_api_key_here",
ndsStore,
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) {
// Process the reverse geocoding error.
Log.d(failure.message)
}
}
val cancellable = reverseGeocoder.reverseGeocode(options, callback)
// You can cancel the operation if needed:
cancellable.cancel()
Content copied to clipboard
Parameters
options
The object containing data for the Reverse Geocoding call.
callback
The callback invoked when the search operation finishes, either successfully or with an error.