Reputation: 31
Im trying reverse geocoding example on mapbox
Everything's working fine. But the problem is when i replace my current location it doesnt return a result. I think that mapbox doesnt have much data about my region (Im in Vietnam). Is there anyway to add my own places supposed that I had a dataset of coordinate and address
My code:
mapboxGeocoding = MapboxGeocoding.builder()
.accessToken(getString(R.string.mapbox_access_token))
.query(Point.fromLngLat(106.799142,10.875838))
.geocodingTypes(GeocodingCriteria.TYPE_ADDRESS)
.build();;
mapboxGeocoding.enqueueCall(new Callback<GeocodingResponse>() {
@Override
public void onResponse(Call<GeocodingResponse> call, Response<GeocodingResponse> response) {
List<CarmenFeature> results = response.body().features();
if (results.size() > 0) {
// Log the first results Point.
//Point firstResultPoint = results.get(0).center();
String country=results.get(0).placeName();
Log.d("Geocoding",country);
} else {
// No result for your request were found.
Toast.makeText(getApplicationContext(), "onResponse: No result found", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Call<GeocodingResponse> call, Throwable throwable) {
throwable.printStackTrace();
}
});
}
@Override
protected void onDestroy(){
super.onDestroy();
mapboxGeocoding.cancelCall();
}
Upvotes: 1
Views: 639
Reputation: 1790
There is currently no way of adding custom POIs to the data powering the Geocoding API, but the workaround is to use the Tilequery API. This API retrieves features from vector tiles based on proximity to a particular geographic coordinate. You can mimic reverse geocoding functionality with custom POIs via the following workflow:
I'd recommend working through this tutorial on making a healthy food finder with the Tilequery API, to gain more intuition about how the API can be used for reverse geocoding with custom POIs. The Tilequery API playground is also an excellent resource for interactive experimentation.
Let me know if something is unclear!
Upvotes: 2