[Vuejs]-Get Latitude and Longitude from google location autocomplete using vue.js in Laravel

0👍

This should do, lat and long are placed on addressData, not on placeResultData where you have info about the place related to that address.

getAddressData: function (addressData, placeResultData, id) {
    this.address = addressData;

    console.log(addressData.longitude);
    console.log(addressData.latitude;

    this.form.address = addressData.route + ', ' + addressData.postal_code + ', ' + addressData.administrative_area_level_2 + ', ' + addressData.country;
  }

Also, I do not think the use of v-model makes much sense here, instead you should store the address directly on the getAddressData function.

<vue-google-autocomplete
    id="map"
    classname="form-control"
    placeholder="Start typing"
    v-on:placechanged="getAddressData"
>
</vue-google-autocomplete>

Leave a comment