大佬教程收集整理的这篇文章主要介绍了尝试将 reverseGeocode 地址作为列表从 Places api 移动到 AddressComponents,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的应用中有几个部分可用于获取(或需要获取)街道地址。
我的方法同时使用 Place API 和 reverseGeocode,并且可以很好地处理它们单独执行的操作。
但是,对于我正在制作的 mod,在某些情况下,我将无法使用 Places API,因此我在下面显示的例程称为 getAddressBuildError() 在那里,我使用 addressComponents 作为从 Place API 获得的列表。
我只能访问reverseGeocode
不过,我正在尝试做的是以某种方式得到这个 - 地址 pCurrent = reverseGeocode(aLocation) - 即“地址”到列表地址组件中,这样我就可以继续应用程序逻辑,因为如果我是,它通常会流动使用 Places API。
这是反向地理编码部分
public voID onLocationUpdate(Location aLocation) {
super.onLocationUpdate(aLocation);
alertDialog.dismiss();
if (null == mCountrIEs) return;
Address pCurrent = reverseGeocode(aLocation);
if (pCurrent == null) {
stopGps();
String message = "Unable to detect country. Please check your network connection or try again.";
Toast.makeText(getContext(),message,Toast.LENGTH_SHORT).show();
exitApp();
return;
}
String strState = pCurrent.getadminArea();
if (!TextUtils.isEmpty(strState)) {
UiUtils.setSpinnerValue(mDriverlicenseState,strState);
}
String strStreet = pCurrent.getAddressline(0);
mAddress.setText(pCurrent.getAddressline(0));
etc etc
}
这是 Place API 部分。
import com.Google.androID.librarIEs.places.API.model.AddressComponents;
private AddressComponents addressComponents;
try {
this.address = place.getAddress();
this.addressComponents = place.getAddressComponents();
String addressBuildError = getAddressBuildError();
etc etc
这是我使用 Places API 中的 addressComponents 的地方。
private String getAddressBuildError() {
String route = null,locality = null,administrative_area_level_1 = null,country = null;
String street_number = null,postal_code = null;
if (addressComponents == null) return getString(R.string.provIDe_address);
List<AddressComponent> addressComponents = this.addressComponents.asList();
for (AddressComponent component : addressComponents) {
if (component.getTypes().contains("street_number")) {
street_number = component.getShortname();
}
and further code follows ...
我试图解决这个问题,将 reverseGeocode androID.location.Address 放入我定义为私有 AddressComponents addressComponents_limit 的“新”字段中,但我无法解决。
然后我可以在一个类似于 getAddressBuildError 的新函数中使用“addressComponents_limit”,但地址信息来自 reverseGeocode .. 但采用 AddressComponents 的格式
提前致谢
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的尝试将 reverseGeocode 地址作为列表从 Places api 移动到 AddressComponents全部内容,希望文章能够帮你解决尝试将 reverseGeocode 地址作为列表从 Places api 移动到 AddressComponents所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。