【发布时间】:2017-07-10 05:19:19
【问题描述】:
我正在尝试从 Google 地点选择器中获取城市名称。有什么方法可以使用地点选择器 API 获取城市名称。我知道我们不能简单地通过放置 place.getCity(); 从 API 获取它下面是我的代码。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_PLACE_PICKER){
if(resultCode==RESULT_OK){
Place place = PlacePicker.getPlace(data,this);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
final CharSequence phone = place.getPhoneNumber();
final String placeId = place.getId();
final LatLng latLng = place.getLatLng();
if(place.getLocale() != null) {
String aname = place.getLocale().toString();
areaname.setText(aname);
}
location.setText(address);
gname.setText(name);
latlon.setText(String.valueOf(latLng));
}
}
}
我不希望城市中有任何空值。我读到Geocoder 会给出大部分为空值。
【问题讨论】:
标签: android google-geocoder gmsplacepicker