Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API V3 Geocoding API not returning state

I need to find out whether a particular (well formatted) address is in "England", "Wales", "Scotland" or "Northern Ireland" if the address is in the UK.

My current requests to the Google Geocoding API return the city (e.g. "London") and the country ("United Kingdom") - both of these are useless to me.

Is there any way I can retrieve the information I need, or is a different web service required?

like image 268
Consultant101 Avatar asked Aug 07 '26 04:08

Consultant101


1 Answers

I'm not sure why the geocoding response does not return the administrative_area_level_1 for the UK when passing a complete address as a parameter.

However, in your case, what I would do is send the town name (instead of the complete address) to the geocoder which will return the data you need. Here some examples:

  • Manchester
  • Cardiff
  • Glasgow

Note that I have added the Region Biasing parameter to the query so you will need to change it if you want to use it outside the UK.

like image 183
pascal Avatar answered Aug 08 '26 22:08

pascal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!