Just use the coordinates to find the postal code, but first, find the coordinates using the address.
$apiKey = 'API_KEY';
$address = '&address='.urlencode($_POST['address'])
$url = "https://maps.googleapis.com/maps/api/geocode/json?key={$apiKey}{$address}";
$resp_json = file_get_contents($url);
// decode the json
$resp = json_decode($resp_json, true);
// get the important data
$lat = $resp['results'][0]['geometry']['location']['lat'] ?? "";
$lng = $resp['results'][0]['geometry']['location']['lng'] ?? "";
$cityCoce = "https://maps.googleapis.com/maps/api/geocode/json?key{$apiKey}&latlng=$lat,$lng";
Google Geocode api not returning postal_code for some 'direct hit' addresses,Google places api not returning postal code for some places,Google Maps API Geocode not returning results on passing postal code as a value to address param,Google geocode api not returning neighborhood in response
$apiKey = 'API_KEY';
$address = '&address='.urlencode($_POST['address'])
$url = "https://maps.googleapis.com/maps/api/geocode/json?key={$apiKey}{$address}";
$resp_json = file_get_contents($url);
// decode the json
$resp = json_decode($resp_json, true);
// get the important data
$lat = $resp['results'][0]['geometry']['location']['lat'] ?? "";
$lng = $resp['results'][0]['geometry']['location']['lng'] ?? "";
$cityCoce = "https://maps.googleapis.com/maps/api/geocode/json?key{$apiKey}&latlng=$lat,$lng";
Just use the coordinates to find the anycodings_google-maps-api-3 postal code, but first, find the anycodings_google-maps-api-3 coordinates using the address.,Now if I enter the exact same string into anycodings_python the official zipcode database (Ireland) it anycodings_python returns the zipcode. ,I would suggest reaching out to the anycodings_google-maps-api-3 Google data team and report the data anycodings_google-maps-api-3 issue as described in their help center:,From double checking on google maps, this is anycodings_python the exact address I want. In other words anycodings_python it's a direct hit.
Python code:
address = '34 new street, Green road, Carlow' geocode_url = "https://maps.googleapis.com/maps/api/geocode/json?address={}&key={}".format(address, api_key) # Ping google for the reuslts: results = requests.get(geocode_url) # Results will be in JSON format - convert to dict using requests functionality results = results.json()
And the results. There should be a anycodings_python postal_code data here, right? There's anycodings_python nothing to say that it was only a partial anycodings_python match.
{
'results': [{
'address_components': [{
'long_name': '34',
'short_name': '34',
'types': ['street_number']
},
{
'long_name': 'New Street',
'short_name': 'New St',
'types': ['route']
},
{
'long_name': 'Moanacurragh',
'short_name': 'Moanacurragh',
'types': ['neighborhood', 'political']
},
{
'long_name': 'Carlow',
'short_name': 'Carlow',
'types': ['locality', 'political']
},
{
'long_name': 'County Carlow',
'short_name': 'County Carlow',
'types': ['administrative_area_level_1', 'political']
},
{
'long_name': 'Ireland',
'short_name': 'IE',
'types': ['country', 'political']
}
],
'formatted_address': '34 New St, Moanacurragh, Carlow, Ireland',
'geometry': {
'location': {
'lat': 52.8296466,
'lng': -6.9331115
},
'location_type': 'RANGE_INTERPOLATED',
'viewport': {
'northeast': {
'lat': 52.83099558029149,
'lng': -6.931762519708498
},
'southwest': {
'lat': 52.82829761970849,
'lng': -6.934460480291502
}
}
},
'place_id': 'EhozNCBOZXcgU3QsIENhcmxvdywgSXJlbGFuZCIaEhgKFAoSCZ93HqizQl1IEZZMDB0YIkdXECI',
'types': ['street_address']
}],
'status': 'OK'
}
Just use the coordinates to find the anycodings_google-maps-api-3 postal code, but first, find the anycodings_google-maps-api-3 coordinates using the address.
$apiKey = 'API_KEY';
$address = '&address='.urlencode($_POST['address'])
$url = "https://maps.googleapis.com/maps/api/geocode/json?key={$apiKey}{$address}";
$resp_json = file_get_contents($url);
// decode the json
$resp = json_decode($resp_json, true);
// get the important data
$lat = $resp['results'][0]['geometry']['location']['lat'] ?? "";
$lng = $resp['results'][0]['geometry']['location']['lng'] ?? "";
$cityCoce = "https://maps.googleapis.com/maps/api/geocode/json?key{$apiKey}&latlng=$lat,$lng";
API Documentation parameters, best practices, response codes , sensor - required by Google as an indicator of whether the request comes from a device with a location sensor; this parameter is ignored by the OpenCage geocoding API. , Here are example responses to reverse and forward geocoding requests with no optional parameters: , We are sometimes asked if the geocoding API supports sending more than one location per request, sometimes referred to as "batch" or "bulk" geocoding. The answer is no.
"rate": {
"limit": 2500,
"remaining": 2498,
"reset": 1605312000
},