Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With the Google API is there anyway to get all of the cities in a state, and all of the towns in a city?

I am trying to build an application where a user can "drill-down" so to speak to find a location. So if they click on "US" it should show all of the states, and if they click a state it should show all of the cities. I have looked at the Google Places API, and I'm not exactly sure what the best method is. I thought about using bounds but I feared it would not be accurate because bounds works off of a rectangle. Not the actual city or state.

like image 924
tylerism Avatar asked Oct 27 '25 14:10

tylerism


1 Answers

There is no any Google Maps API that can return a list of cities in the state. The Google APIs does not work this way, they are not like a database search.

You can try a Places API autocomplete, but this API returns up to 5 suggestions when you are typing a text. You cannot define a strict filter by city or state, you can only bias result to certain view port.

like image 95
xomena Avatar answered Oct 29 '25 07:10

xomena



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!