Last active
July 17, 2019 06:26
-
-
Save bayareawebpro/a90f5e21e3822da963a8362b0c1ece9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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