Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API to type city name and get a list of possible cities? [closed]

I need to know on which city my users are.

I cannot use a regular text input since there are similar named cities and users can call the same city by different names,.

I want to let users type their city and display a list of similar results, I could do it with a world cities database, jquery and sql but I'm really not dying to do it from a scratch.

Is there any api (e.g: google) that has an unique ID for each city in the world and let's you search them? Could you post a link to a similar implementation?

like image 670
lisovaccaro Avatar asked Aug 08 '12 06:08

lisovaccaro


People also ask

How do I get my city name from places API?

2) Make another web-service call to https://maps.googleapis.com/maps/api/place/details/json?key=API_KEY&placeid=place_id_retrieved_in_step_1. This will return a JSON which contains address_components . Looping through the types to find locality and postal_code can give you the city name and postal code.

Is Google Maps API free?

The API is available for developers that have a free Google Maps API key. Usage of the API is not strictly free, but they do offer $200 of free monthly usage for most users. The pricing scales to fit your particular needs and you are only charged for your API usage.

How do I use Google Places Autocomplete API?

Ensure that the API key(s) used for all Place Autocomplete and Place Details requests within a session belong to the same Cloud Console project. Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually.


1 Answers

There is the Google Places Autocomplete API, https://developers.google.com/places/documentation/autocomplete

and a library for Maps Version 3 at https://developers.google.com/maps/documentation/javascript/places#places_autocomplete

but I don't know how well it will cope with different names for the same city — although, having tried it, it does present Munich, Germany for munchen — see how well your use case performs.

like image 182
Andrew Leach Avatar answered Sep 22 '22 12:09

Andrew Leach