简体   繁体   中英

Address Auto complete using Google Maps API

I am currently using google maps api to suggest addresses as user types into an input field. When they select one of the drop down suggestions provided by google, the state/province gets automatically updated.

I was wondering if there was a way to update the state/province without selecting the suggestions google provides? Maybe a user neglects to select a provided option, how do you then automatically update the state/province

example - https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

Since the data is stored in google's database,I don't think you can update automatically if you don't click on an element of the list, because if you don't click, the google object is not created.

You can still try to convert the value of your input text into a google object but i don't think it's possible (if it is not a google.maps.places.Autocomplete object you can't use getPlace() ).

I tried it already because i was facing the same problem and din't find a solution either, maybe you will manage to convert the input into a google.maps.places.Autocomplete object. It's the only way if you want to use the data of google.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM