You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
922 B

import { mapState } from 'vuex'
import { calculateDistance } from '@/utils/position'
export default {
data() {
return {
}
},
computed: {
...mapState(['position']),
},
methods: {
calculateDistanceAddress(teacherAddress) {
if (!teacherAddress ||
teacherAddress.length == 0 ||
!this.position ||
!this.position.latitude ||
!this.position.longitude) {
return 0
}
let minDistance = 0
teacherAddress.forEach(item => {
let distance = calculateDistance(
this.position.latitude,
this.position.longitude,
item.latitude,
item.longitude,
)
minDistance = Math.min(minDistance, distance)
})
return minDistance
}
}
}