ignorieren alles, nachdem Sie die Google Maps API verwenden können, normalisierte Adresse zu erhalten:
1) Lassen Sie sich von Folge: https://maps.googleapis.com/maps/api/geocode/json?address=san_francisco
{
"results" : [
{
"address_components" : [
{
"long_name" : "San Francisco",
"short_name" : "SF",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Condado San Francisco",
"short_name" : "Condado San Francisco",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Estados Unidos",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "San Francisco, California, EE. UU.",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 37.9298239,
"lng" : -122.28178
},
"southwest" : {
"lat" : 37.6398299,
"lng" : -123.173825
}
},
"location" : {
"lat" : 37.7749295,
"lng" : -122.4194155
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 37.812,
"lng" : -122.3482
},
"southwest" : {
"lat" : 37.70339999999999,
"lng" : -122.527
}
}
},
"place_id" : "ChIJIQBpAG2ahYAR_6128GcTUEo",
"types" : [ "locality", "political" ]
}
],
"status" : "OK"
}
2) Extrahieren Sie den Namen der Stadt von $data['results'][0]['address_components'][0]['long_name']
.
Sie sollten überprüfen, ob der zurückgegebene Inhalt die beschriebenen Felder enthält und $data['status']
ist "OK".
Quelle: https://developers.google.com/maps/documentation/geocoding/intro
Dank für die Anregung. Es ist nicht im Einklang du :( – Sahas