title: Vuejs variable using in function google maps matrix api problem
body: <p>Vuejs variable using in function google maps matrix api problem.
  I am using Google distance matrix api to get the distance between two locations. I declared a variable globally. Changed this variable in function. But as per normal circumstances I should be able to access this changed value of variable after calling my function. But now I am not being able to access the changed value of variable</p>
  <p><strong>using : Matrix google maps api + autocomplete input place api</strong></p>
  <pre><code>export default {
  data () {
    return {
        data:{
            adrdep:{adrs:'',lat:0,lng:0},
            adrarr:{adrs:'',lat:0,lng:0},
            distance:0,
            date:null,
            time:null,
            check:false,
            camion:'',
            etage:9,
            assenseur:'assenseur'
        }
    }
  },
  methods: {
    
    getAddressDatadep: function (addressData, placeResultData, id) {
              this.data.adrdep.lat =addressData.latitude;
              this.data.adrdep.lng = addressData.longitude;
    },
    getAddressDataArr: function (addressData, placeResultData, id) {
              this.data.adrarr.lat = addressData.latitude;
              this.data.adrarr.lng = addressData.longitude;
    },
    async getDistance(){
      
          var a1={lat:this.data.adrdep.lat,lng:this.data.adrdep.lng};
          var a2={lat:this.data.adrarr.lat,lng:this.data.adrarr.lng};
          var p1 = new google.maps.LatLng(a1.lat, a1.lng);
          var p2 = new google.maps.LatLng(a2.lat, a2.lng);
          var origins = [a1.lat + &quot;,&quot; + a1.lng];
          var destinations = [a2.lat + &quot;,&quot; + a2.lng];
  
          var distanceMatrix = new google.maps.DistanceMatrixService();
          var distanceRequest = {
              origins: origins,
              destinations: destinations,
              travelMode: google.maps.TravelMode.DRIVING,
              unitSystem: google.maps.UnitSystem.METRIC,
              avoidHighways: false,
              avoidTolls: false
          };
           distanceMatrix.getDistanceMatrix(distanceRequest, function(response, status)  {
              var totalDistance
              if (status != google.maps.DistanceMatrixStatus.OK) {
                  console.log(&quot;error&quot;)
              } else {
                  var origins = response.originAddresses;
                  var destinations = response.destinationAddresses;
                  //debugger;
                  if (response.rows[0].elements[0].distance != null) {
                       totalDistance = response.rows[0].elements[0].distance.value;
                      var totalTime = response.rows[0].elements[0].duration.value;
                      var ratioPerOneMeter = totalDistance / totalTime;
                      var PRDifference = 0;
                      this.data.distance=totalDistance*0.001;
                      console.log(&quot;return distance&quot;)
                  } else {
                      console.log('The Distance And Time Cannot Be Calculated')
                  }
              }
              return totalDistance*0.001;
          });
      
    }
  </code></pre>
  <p>};</p>
  <p>plz help me :)</p>