문제

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?

도움이 되었습니까?

해결책

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

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top