Skip to content

Instantly share code, notes, and snippets.

@bayareawebpro
Last active July 17, 2019 06:26
Show Gist options
  • Save bayareawebpro/a90f5e21e3822da963a8362b0c1ece9a to your computer and use it in GitHub Desktop.
Save bayareawebpro/a90f5e21e3822da963a8362b0c1ece9a to your computer and use it in GitHub Desktop.
<template>
<div class="form-group">
<label for="location">{{ label }}</label>
<input type="text" id="location" :value="value" ref="location" class="form-control" />
</div>
</template>
<script>
export default {
props: {
value: {
required: false
},
label: {
required: false
}
},
name: "GeoLocation",
methods: {
isLoaded(){
if ('google' in window && google.maps && google.maps.places) {
clearInterval(this.googleLoaded)
this.initInput()
}
},
initInput() {
this.autocomplete = new google.maps.places.Autocomplete(
(this.$refs.location),
{types: ['geocode']}
);
}
},
data(){
return{
autocomplete: ''
}
},
mounted() {
this.googleLoaded = setInterval(this.isLoaded, 100)
}
}
</script>
<style scoped>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment