For Social Website where the user should specify his or her Area of Residence. I want to use the same method Facebook does; a text input field with a dynamic drop-down menu as you type.

I am using the GeoIP databases. However, there are a number of issues that I see:

  • I want to divide each country in a sensible number of areas. In Norway, GeoLiteCity lists over 3000 "places", most of which are very small places no-one has heard of, and is "too local" (may compromise privacy). However, Norway has 430 "communes", which seems like a perfect granularity to me.
  • However, to use administrative place names, you would have to figure out the administrative level system for each country in the world, which seems like an insane task. For example, Canada has an administrative division system that differs for each province. And France has over 30.000 "communes" and around 3.000 "cantons". Which level do you choose?
  • Also, when picking out entries that are "ADM" (Administrative Level), the names of places often have long prefixes or suffixes, like "Politischer Berzirk Deutschlandsberg" in Austria, rather than just "Deutschlandsberg" which is what you want to display in a drop-down.
  • Then there is the issue of places with identical names. There are hundreds places called "San Antonio". Then you need to say which San Antonio, and you soon realize you're in hell trying to puzzle this together for hundreds of thousands of places around the world.

Is there any joined effort to organize and wash the GeoIP database into unique place names of administrative divisions that are as short as possible?

Are there other approaches to this that would elegantly shake off these issues?

2 Answers 2


There is a very useful part of the Google Places API for this, called Places Autocomplete. You can simply add the event listener to an input box and it will generate place suggestions as you type just like it does on Google, and you can extensively customise the way it shows the search results through the JavaScript API.

You then have the option to take the text-based search result and run it through the Place Details part, and you can find out the longitude and latitude plus a bunch of other stuff you may or may not need.

It also has all the smarts of Google's algorithms, it can even provide suggestions for misspelled place names.

Partial Screenshot of Google Maps Places Autocomplete example

See a working version of the above screenshot example here.

  • Great suggestion, but Places Autocomplete does not seem to return longitude and latitude. Must I do autocomplete first, and then grab the full place name ("Kilburn, South Australia, Australia" in this example) to look up the longitude and latitude using another part of Google Maps API?
    – forthrin
    Aug 18, 2013 at 20:17
  • 1
    @forthrin You can use Place Details Requests to get that information, additional code but easy enough. :)
    – Dom
    Aug 18, 2013 at 20:30

While I'm not familiar with the GeoIP database specifically, it sounds like it would be incredibly difficult to merge specific places (cities, towns) into regions of a comparable size to Norway's communes on a global basis. Even if you could, the labels given are unlikely to match the users' mental models of how their country is subdivided. Even two people who live in the same city may think about it differently.

If your goal is to have users specify their location and find others nearby, without revealing enough detail to compromise privacy. It's common to request a user's specific location (which can be found by searching the list of places you have) and then show other users within a radius of that. So long as you make it clear that their exact location is private, you should have the benefit of grouping nearby users without introducing any confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.