Esiste un modo per ottenere il codice postale della posizione dell'utente corrente da posizione o latitudine o longitudine. Se sì, come?Codice postale dalla posizione
risposta
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
Usa Android Geocoder API!
getFromLocation (double, double, int) è tutto ciò che serve.
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à.
thanx ... fammi provare – Udaykiran
Dal primo ... non esiste un codice postale per rientrare – Udaykiran
@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