Webservice for autorun on city names / postal codes, including long-lat coordinates?

I am looking for a web service that will be used for an autocomplete field where people can fill in a zip / city name or both

This service will require all cities in Europe , so we can use it for all the websites of the country. and at a later stadium we want to keep the world open to Asia and America, so this will be a plus.

it is desirable that it also returns long-lat coordinates for locations,

Now this is a free text field, after leaving the field we got into the google geocoding service, find the coordinates ... preferably, I would link the two together. therefore we do not need to request 2 services for one thing.

Does anyone know about the existence of such a service on the Internet? or would you suggest creating our own database with cities / postal codes / coordinates? if so, we would need to get the content from somewhere too, and I tried to avoid this problem :)

+2
source share
2 answers

I recently looked for a similar service, in vain.

I wanted my users to have auto-completion when entering the city name, and as soon as the city was selected, I needed to pass the name and lat / long to the Google API. In the end I did this: -

  • downloaded geonames allcountries.zip, full extract: this
  • Imported into SQL DB via SSIS (about 7.5 million records!)
  • I wrote a simple request to retrieve only cities (only PPLC, PPLA and PPLA2 records).

This left me with a managed table of 9112 entries (with lat / long and country code) that covers all cities of the world. Then I wrote my own code to request data.

Not perfect, but I need a solution.

+4
source

I know this post is very old, but for those who are looking for a simple solution that can be integrated in 5 minutes, here is the link: Geocomplete jQuery ...

In my case, I followed these steps:

1 - Download the plugin from here .

2 - Add the jquery.geocomplete.js or jquery.geocomplete.min.js file to the javascript folder of your project.

3. Call this file in the script tags on the html page, where you have an input field that you must autocomplete with cities: <script src='/PathToTheFile/jquery.geocomplete.js'></script>

4 - To convert an input to an autocomplete field, simply call the Geocomplete plugin in the script tags: <script> $("#IdOfTheInputField").geocomplete(); // Option 1: Call on element. $.fn.geocomplete("input"); // Option 2: Pass element as argument. </script> <script> $("#IdOfTheInputField").geocomplete(); // Option 1: Call on element. $.fn.geocomplete("input"); // Option 2: Pass element as argument. </script>

5- You can check the complete list of options in the link above.

Hope this helps!

+1
source

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


All Articles