Question

See the screenshot here:
http://media-cdn.pinterest.com/upload/185773553348981093_6T1oUT9E.jpg

I'd like the user to just type a city or country name and the autocompleter will show suggested items.

How should I start for creating it? Are there any API(s) or web services for me to call? Where can I find the database of all cities/countries in the world?

Was it helpful?

Solution

I think this would be the best database for your situation, check it out:

http://www.geodatasource.com/cities-free.html

OTHER TIPS

You first need a autocomplete plugin.
I recommend to use the jQuery-Ui Auto Complete Plugin.

The database could as example be this, but eventually try to search a bit for yourself.
There was already a question on stackoverflow about a database for cities of the world.
A simple text file with all cities may also be this.
There are very much of those libraries, but you have to chose the right one for you.

My solution may not be the best, but it's a starting point: Google a list with all countries (ISO-Standard), paste it into a txt-file. Then you can simply read that file with PHP an create a select menu with the contents of the file. It does not incorporate the cities, but maybe it helps you in some way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top