【发布时间】:2020-11-05 06:10:03
【问题描述】:
我在 mapbox 上尝试reverse geocoding example
一切正常。但问题是当我替换我当前的位置时,它不会返回结果。 我认为 mapbox 没有太多关于我所在地区的数据(我在越南)。假设我有一个坐标和地址数据集,是否可以添加我自己的地方
我的代码:
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();
}
【问题讨论】:
标签: android mapbox reverse-geocoding