2016-08-18 3 views
1

Place.classには都市、国、住所、住所が含まれていますが、私は で区切ります。ありがとうございます!Google Place Pickerは街を取得しますか?

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 

     if(resultCode==RESULT_OK){ 
     final Place place = PlacePicker.getPlace(this,data); 
     final CharSequence name = place.getName(); 
     final String address = place.getAddress()+""; 
     String attributions = (String) place.getAttributions(); 
     if (attributions == null) { 
      attributions = ""; 
     } 
     et_city.setText(address); 
     et_post.setText(address); 
     et_street.setText(address); 
     } 
    } 
+0

あなたは必要な詳細を得ることができましたか?あなたは答えを受け入れることができますか? –

答えて

3

あなたを助けるかもしれない、私はすでに同じ質問に答えている。この

final Place place = PlacePicker.getPlace(this,data); 
Geocoder geocoder = new Geocoder(this); 
try 
{ 
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude,place.getLatLng().longitude, 1); 
    String address = addresses.get(0).getAddressLine(0); 
    String city = addresses.get(0).getAddressLine(1); 
    //String country = addresses.get(0).getAddressLine(2); 

} catch (IOException e) 
{ 
    bottomSheetAddress.setText("Not Available."); 
    e.printStackTrace(); 
} 
+0

* Geocoder *は、AOSPの一部ではないGoogle APIアドオンの一部です。 –

0

をやってみてください。あなたはそれを見つけることができますhere.

関連する問題