Una breve nota per coloro che trovare questo SO rispondere. La risposta di Daniel Vassallo utilizza l'API V2 di Geocoding di Google, che ora è stata ritirata. La nuova API v3 utilizza un formato di richiesta simile:
http://maps.googleapis.com/maps/api/geocode/output?parameters
Un esempio per un codice postale di ricerca, restituendo i dati in formato JSON è:
http://maps.googleapis.com/maps/api/geocode/json?address=SL59JH,+UK&sensor=false
Questo restituisce una matrice JSON che include il lat e a lungo in risultati-> geometria;> Località-> lat e Risultati> geometria;> Località-> lng
Esempio di risposta:
{
"results" : [
{
"address_components" : [
{
"long_name" : "SL5 9JH",
"short_name" : "SL5 9JH",
"types" : [ "postal_code" ]
},
{
"long_name" : "Windsor and Maidenhead",
"short_name" : "Windsor and Maidenhead",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "United Kingdom",
"short_name" : "GB",
"types" : [ "country", "political" ]
},
{
"long_name" : "Ascot",
"short_name" : "Ascot",
"types" : [ "postal_town" ]
}
],
"formatted_address" : "Ascot, Windsor and Maidenhead SL5 9JH, UK",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 51.39655490000001,
"lng" : -0.66024660
},
"southwest" : {
"lat" : 51.39457330,
"lng" : -0.6624574999999999
}
},
"location" : {
"lat" : 51.39539040,
"lng" : -0.66096740
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 51.39691308029150,
"lng" : -0.6600030697084980
},
"southwest" : {
"lat" : 51.39421511970851,
"lng" : -0.6627010302915021
}
}
},
"types" : [ "postal_code" ]
}
],
"status" : "OK"
}
Le specifiche API sono disponibili qui: https://developers.google.com/maps/documentation/geocoding/
@Daniel ... Grazie mille per il tuo feedback ... risolverò le tue soluzioni e ti ricontatterò ... – Nirmal
Funziona ancora usando gli esempi sopra riportati nel mio browser. Ricevo 610,0,0,0. Non importa quale codice postale campionerò, sempre 610,0,0,0? – QFDev
Penso che questo sia dovuto al fatto che gli esempi in questa risposta utilizzano una versione precedente dell'API delle mappe. Un nuovo esempio sarebbe come questo: http://maps.googleapis.com/maps/api/geocode/json?address=SL59JH,+UK&sensor=false. Ovviamente la query per estrarre il lat/lng dovrebbe essere cambiata poiché l'output sta ora restituendo JSON piuttosto che CSV. – Dan