World cities database

I am currently working on a project that is focused around locations. The main thing I need to know is the City that the user is either in or wants to browser information about. It is a mobile website so I am giving the user a couple of options how to pick their location.

On the page where the users selects the location the first button is to allow them to use the browser to set their location ‘Use my precise location’

There is another button that uses a IP geolocation script which should say ‘Cityname’ which should be the city in which the user is.

The third option is to list a load of cities for the user to click to choose.

I am saving the latitude and longitude to be used throughout the application. The browser will return this, the geoIP will return this so I needed a way to get the latitude and longitude for each city I wanted to list. I started buy using Google APIs which worked well. I stored this information in a database table. The problem was that I wanted to give the user as many options as possible and I wanted to use cities in the US. I went on the hunt for a database and successfully found a couple of resources which had exactly the information I needed. One of them even had population so I was able to use this information alongside our other background research to influence our decision on which cities we would actually list so we were not trying to list all of them!

I thought I would share these two links are they will probably be of use to me in the future and I hope this will help someone else out.

Thanks to Brian Suda and Rick Trotter for the replies to my original Tweet.

A little something extra: Thanks to a Tweet from Philip Poots I have recently found out that if you append .json to the end of any gov.uk page you will get the information in json format! For example, if you wanted to know all the UK bank holidays then you can find this information at https://www.gov.uk/bank-holidays and if you add .json to the end… https://www.gov.uk/bank-holidays.json! This is awesome!

Leave a Reply

Your email address will not be published. Required fields are marked *