Open AbdurRehman26 opened 6 years ago
Not sure if you are still looking for the solution, but this is how I achieved it.
First, Add a reference to GMapAutocomplete component -
<GmapAutocomplete ref="autocomplete" :position.sync="markers[0].position" @keyup.enter="usePlace" @place_changed="setPlace"></GmapAutocomplete>
And then in your updateMarker method (on dragend), add this
updateMaker: function(event) {
let geocoder = new google.maps.Geocoder()
geocoder.geocode({ 'latLng': event.latLng }, (result, status) => {
if (status ===google.maps.GeocoderStatus.OK) {
// accessing autocomplete reference and populating the address
this.$refs.autocomplete.$refs.input.value = result[0].formatted_address
}
})
}
how to import google in updateMarker event
import { gmapApi } from 'vue2-google-maps'
computed: {
...mapState(...),
google: gmapApi,
// other methods
}
updateMaker: function(event) {
let geocoder = new this.google.maps.Geocoder()
....
}
Hi i think i have read this issue in the issues list but i am not sure. I have implemented the plugin and it works flawlessly but there is a small problem ( or maybe i am not able to do it correctly ). When i implemented the autocomplete functionality it works one way. I enter the address and the map points me to the selected place but when i drag the pointer it doesnt update the address in the search field. This is what i am doing