2011-10-25 15 views

答えて

3

ジオコーディングを使用できます。私はそれが役に立てば幸いあなたがあなた自身のアプリ(コピー/ペースト)

でそれを試すことができるというそこのコードを見つけることができ、それはジオコーディングを言うthis linkの指示に従い、

を逆ジオコーディング:)

0
 try { 
     Geocoder geocoder; 
     List<Address> addresses; 
     geocoder = new Geocoder(MainActivity.this); 
     Toast.makeText(this, "before if", 
       Toast.LENGTH_LONG).show(); 

     if (latitude != 0 || longitude != 0) { 
      addresses = geocoder.getFromLocation(latitude , 
        longitude, 1); 
        String address = addresses.get(0).getAddressLine(0); 
     String city = addresses.get(0).getAddressLine(1); 
     String country = addresses.get(0).getAddressLine(2); 
      Log.d("TAG", "address = "+address+", city ="+city+", country = "+country); 
     Toast.makeText(this, "address = "+address+", city ="+city+", country = "+country, Toast.LENGTH_LONG).show(); 

     } 
     else { 
      Toast.makeText(this, "latitude and longitude are null", 
        Toast.LENGTH_LONG).show(); 

     } 
    } catch (Exception e) { 
     e.printStackTrace(); 

    } 
関連する問題