I am working with a code sample that contains data for cities including latitude and longitude values.
Here is the code snippet:
...
methods: {
mapDrag: function () {
let lat = 100;
let lng = 200;
this.cities.forEach(function (city, index, array){
let distance = this.calculateDistance(city.latitude, city.longitude, lat, lng)
console.log(distance)
});
},
calculateDistance: function (lat1, long1, lat2, long2) {
// implementation of distance calculation
},
},
...
However, when the mapDrag method is called, an error occurs:
[Vue warn]: Error in v-on handler: "TypeError: Cannot read properties of undefined (reading 'calculateDistance')"