2011-05-02 14 views

risposta

5

Sì, è possibile ... Tutto quello che devi fare è estrarre la latitudine

http://maps.google.com/maps/geo?ll=, longitudine

http://maps.google.com/maps/geo?ll=10.345561,123.896932 

Oppure provate a sperimentare questo solutions.I può dare un'idea.

Puoi avere una città giusta? Con questo json dati, se avete un database (a maxmind.com) del codice postale con questo formato

CountryCode | Città | CAP


PH | Cebu | 6000

Ora interrogare il database che è relativo al countrycode che googles rendimento.

UPDATE

L'API v2 Geocoding sia stato abbassato il 9 settembre 2013.

Ecco il nuovo URL del servizio API

http://maps.googleapis.com/maps/api/geocode/json?latlng=your_latitude,your_longitude

http://maps.googleapis.com/maps/api/geocode/json?latlng=10.32,123.90&sensor=true

+0

thanx ... fammi provare – Udaykiran

+1

Dal primo ... non esiste un codice postale per rientrare – Udaykiran

+0

@Udaykiran hai bisogno di un altro database che abbia un record di un codice postale.Questo è l'esempio del database.http://ipinfodb.com/zipcode_database.php – kedomonzter

7

Usa Android Geocoder API!

getFromLocation (double, double, int) è tutto ciò che serve.

2

implementazione basata Geocoder:

private String getZipCodeFromLocation(Location location) { 
    Address addr = getAddressFromLocation(location); 
    return addr.getPostalCode() == null ? "" : addr.getPostalCode(); 
} 

private Address getAddressFromLocation(Location location) { 
    Geocoder geocoder = new Geocoder(this); 
    Address address = new Address(Locale.getDefault()); 
    try { 
     List<Address> addr = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); 
     if (addr.size() > 0) { 
      address = addr.get(0); 
     } 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    return address; 
} 

È possibile ottenere anche altre informazioni dall'indirizzo, ad esempio nome della città.