I have looked at the links but cannot find a simple example of reverse geocoding using the Mapbox API.
Does anybody have a link to a simple partial address input and a response?
Why wouldn't the example's in: https://docs.mapbox.com/api/search/#reverse-geocoding work for you ?
At least when trying those quickly with browser, they return nice JSON reply. So for Reply, just copy paste the url into your browser, and let it load the response.
Reference
https://docs.mapbox.com/help/how-mapbox-works/geocoding/
Examples
Place to Co-ordinates
example query for the address “515 15th St NW, Washington, DC 20004”,
Co-ordinates to Place
Try this my friend, point is a type you can construct easily with Point.fromLngLat(point.longitude(), point.latitude())
private fun reverseGeocode(point: Point) {
try {
val client = MapboxGeocoding.builder()
.accessToken(getString(R.string.mapbox_access_token))
.query(Point.fromLngLat(point.longitude(), point.latitude()))
.geocodingTypes(GeocodingCriteria.TYPE_ADDRESS)
.build()
client.enqueueCall(object : Callback<GeocodingResponse>
{
override fun onResponse(call: Call<GeocodingResponse>, response: Response<GeocodingResponse>) {
if (response.body() != null) {
val results = response.body()!!.features()
if (results.size > 0) {
val feature = results.get(0)
Log.d(TAG, "lig Current location is ${feature.placeName()}")
} else {
Log.d(TAG, "lig Current location is nothing")
}
}
}
override fun onFailure(call: Call<GeocodingResponse>, throwable: Throwable) {
Log.e(TAG, "Geocoding Failure", throwable)
}
})
} catch (servicesException: ServicesException) {
Log.e(TAG, servicesException.toString())
servicesException.printStackTrace()
}
}