简体   繁体   中英

Query Google Maps for surrounding cities to a location

I am new to using Google Maps API. I have a problem that I want to solve. I have a ZIP code and city name and an input and I want to get the names and ZIP codes of all the cities surrounding the input in a specific radius.

Is there a way to do this using Google Maps API or is there any other way ?

No. The Google Maps API doesn't have a proximity search. You can make yourself one with the harvesine formula or a space filling curve, ie a spatial index.

Proximity search/nearby places isn't part of the Google Maps API. However there are third-party providers that may meet your requirement. The first that comes to mind is geonames , this webservice seems like it might be what you are looking for.

Example

While it's not available, you might try with the Places API, searching for something unique (ie 1 per city) in a set radius. Maybe try with a search for "city hall" around ZIP code XXXXX, radius 30 mi. See if that yields valid results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM