Search code examples
web-servicesautocompletegeolocation

webservice for autosuggest on city names / postal codes including long-lat coordinates?


i'm looking for a webservice, to be used for an autocomplete field, where people can fill in either a postal code / city name or both

this service will need all cities in Europe, so we can use it for all country websites. and in a later stadium we want to keep the world open for asia and america so this would be a plus.

preferably it would also return the long-lat coordinates for the locations,

Now it is a free textfield, after leaving the field, we hit the google geocoding service, to find coordinates... preferably i would tie these two together. so we don't have to query 2 services for one thing.

does anyone know of the existance of such a service online somewhere? or would you suggest to build our own database with cities / postal codes / coordinates? if so we would need to get the content from somewhere too, and i was trying to avoid that issue :)


Solution

  • I recently searched for a similar service, in vain.

    I wanted my users to have auto-complete on entering a city name, and once a city is chosen I needed to pass the name and lat/long onto the Google API. In the end I did this: -

    1. downloaded the geonames allcountries.zip, full extract: this
    2. Imported it into a SQL DB via SSIS (about 7.5 million records!)
    3. Wrote a simple query to extract just the cities (only the PPLC, PPLA and PPLA2 records).

    This left me with a manageable table of 9112 records (with lat / long and country code) which covers all the cities in the world. I then wrote my own code to query the data.

    Not ideal, but I needed a solution.