简体   繁体   中英

place google autocomplete address info on page, not in form

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

I would like to display the City, State and Country (in format: City, State, Country) from an autocomplete on the page, but not in a form. As the user selects the autocomplete, I would like that info to display as they select it, as a sort of headline on the current page, not on a subsequent page.

Should I put separate Divs back to back with the Ids from the autocomplete?

Youll notice on this page, for example, as soon as you choose the autocomplete, your location is made into the 'headline' of the page instantly. http://latestweatheralerts.com/

Thanks

As the docs added demo code:

var autocomplete = new google.maps.places.Autocomplete(input); 
autocomplete.bindTo('bounds', map);

autocomplete.addListener('place_changed', function() {
    var place = autocomplete.getPlace(); 
    //Now do something with the place object properties 
}); 

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