How to make a dropdown menu of cities / countries, how does facebook do it?

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

I would like the user to simply type in the name of a city or country, and autorun displays the suggested items.

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

+4
source share
3 answers

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

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

+4
source

First you need an autocomplete plugin.
I recommend using jQuery-Ui Auto Complete Plugin .

The database might look like this , but ultimately try to look a bit for yourself. There was already a question fooobar.com/questions/1398463 / ... about the database for cities in the world.
A simple text file with all cities could also be this .
There are so many of these libraries, but you have to choose the right one for you.

+1
source

My solution may not be the best, but this is the starting point: Google list with all countries (ISO-Standard), insert it into a txt file. Then you can simply read this file with PHP and create a selection menu with the contents of the file. It does not include cities, but perhaps it helps you in some way.

0
source

Source: https://habr.com/ru/post/1398461/


All Articles