John
John

Reputation: 4028

Auto complete city names using jquery

I want to perform auto complete city names feature (in Vietnamese language) of many countries.

what i have found is: http://www.jqueryscript.net/form/City-Autocomplete-Plugin-with-jQuery-Google-Places-API.html

However problems are:

  1. it completes city names in English.

  2. I want to restrict to only a few cities of a certain countries.

For example, I just want Tokyo, Osaka, Fukuoka for Japan. Adelaide, Sydney for Australia.

  1. It only allows to select city of one country.

code:

`<input id="city" name="city" class="form-control" autocomplete="off" data-country="jp">`

What if I want to auto complete cities of 5 countries?

Could you please guide different methods for me?

Thanks

Upvotes: 0

Views: 2686

Answers (1)

Jacob
Jacob

Reputation: 2071

The code you embed isn't really helpful.

To fix the language problem, change the &language= in the head to desired language. For example, in swedish: &language=sv

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&language=en"></script>

To fix your other problems you actually have to modify the original script. I suggest you find another script that let you create your own array of results instead of pulling from Google Maps.

Maybe this one: https://github.com/devbridge/jQuery-Autocomplete

If you really want the script you already selected I suggest that you read the license and see if you are permitted to change and if so, remove the part that sends a request to google maps api and create a identical array but with your own values instead.

Upvotes: 1

Related Questions