<template>
    <span style="padding-left: 16rpx">{{ tofixedAndKmM(distance) }}</span>
</template>

<script setup>
import { inject } from 'vue';
const { haversine, getDistanceFromLatLonInKm } = inject('globalFunction');
const { alat, along, blat, blong } = defineProps(['alat', 'along', 'blat', 'blong']);
const distance = getDistanceFromLatLonInKm(alat, along, blat, blong);
function tofixedAndKmM(data) {
    const { km, m } = data;
    if (!alat && !along) {
        return '--km';
    }
    if (km > 1) {
        return km.toFixed(2) + 'km';
    } else {
        return m.toFixed(2) + 'm';
    }
}
</script>

<style></style>
