I am implementing google.maps.DistanceMatrixService()
When I test I am getting a weird anomaly and it is not consistent. As I am driving towards to destination I am hitting a button that checks my distance. each time I hit the button it shows that my distance is getting closer (shorter) then out of the blue the distance jumps up (clearly not an accurate reading) as soon as I hit the button again it is back to normal.
Does anyone have any insight to this anomaly or issue?
here is my code. I am using Vue.js
googleMapsMatrix(lat1, lon1, lat2, lon2) {
let origin = new google.maps.LatLng(lat2, lon2);
let destination = new google.maps.LatLng(lat1, lon1);
let service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [origin],
destinations: [destination],
travelMode: 'DRIVING',
// transitOptions: TransitOptions,
// drivingOptions: DrivingOptions,
unitSystem: google.maps.UnitSystem.IMPERIAL,
// avoidHighways: Boolean,
// avoidTolls: Boolean,
}, (response, status) => (this.googleMatrixCallback(response, status, lat2, lon2) ));
},
googleMatrixCallback(response, status, lat2, lon2) {
console.log(response, status, lat2, lon2)
}