Skip to content

Instantly share code, notes, and snippets.

@DanielSmith
Created April 16, 2019 15:25
Show Gist options
  • Save DanielSmith/0200176c4cf371771b6e785a7e191ac3 to your computer and use it in GitHub Desktop.
Save DanielSmith/0200176c4cf371771b6e785a7e191ac3 to your computer and use it in GitHub Desktop.
Get autocomplete address and broadcast it
initMapAutocomplete() {
this.geocoder = new google.maps.Geocoder();
const input = document.getElementById('pac-input');
const autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, 'place_changed', () => {
const place = autocomplete.getPlace();
// we need to update the map
eventBus.$emit('newTextAddress', place);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment