Reputation: 11
I'm trying to get the value of place.formatted_address, but I don't understand why it's undefined everytime I try to console log the value. I'm using this project for the autocomplete function in google maps
const google = window.google;
const options = {
componentRestrictions: { country: "mo" },
fields: ["address_components", "geometry", "icon", "name"],
strictBounds: false,
types: ["establishment"],
};
const autocomplete = new google.maps.places.Autocomplete(this.$refs["origin"], options);
google.maps.event.addListener(autocomplete, "place_changed", () => {
const place = autocomplete.getPlace();
console.log(place.formatted_address)
var lat = place.geometry.location.lat();
var lng = place.geometry.location.lng();
console.log(lat,lng)
})
},
Upvotes: 1
Views: 383