puchu
puchu

Reputation: 3652

how to select all cities using google map api v3

I think a possible way is:

service.search({
    types: ["city"],
    bounds: founded_bounds
}, function(places, status) {});
  1. Select country/state bounds using usual Geocoder service
  2. Make place search request

But there is no "city" type in available places types. How to get all cities in selected country/state?

UPD Thanks to bweaver, locality <=> city

But now I have another trouble: google map place search work real absurd! I made little demo to show the problem. I will post it to google api bugtracker too.

*see console F12
Search for places in Hawaii (all types): 21
Search for places in Honolulu (all types): 22

This is unreal.

Upvotes: 1

Views: 2576

Answers (1)

puchu
puchu

Reputation: 3652

I found a solution. it doesn't belong to google map api but it works (formatted=true is optional)

  1. http://ws.geonames.org/countryInfoJSON?country=US&formatted=true important data: "geonameId": 6252001
  2. for geonameId do recursive search (deep for 3-4 levels will be enough i think) http://ws.geonames.org/childrenJSON?geonameId=6252001&style=full&maxRows=1000&formatted=true
  3. filter results by "fclName" parameter has "city, vilage" substring

Using this logick I will create script generated json files to each state. This script will be worked as cron job each month

If anyone knows how to make such task using google map api - please post!

Upvotes: 1

Related Questions