diff --git a/src/components/MapCheckin.vue b/src/components/MapCheckin.vue index de208fd..72db935 100644 --- a/src/components/MapCheckin.vue +++ b/src/components/MapCheckin.vue @@ -7,13 +7,13 @@ const center = ref() const location = ref('') const test = ref() -const emit = defineEmits(["update:location"]); +const emit = defineEmits(['update:location']) const updateLocation = (location: any, namePOI: string) => { // ส่ง event ไปยัง parent component เพื่ออัพเดทค่า props - emit("update:location", location, namePOI); -}; + emit('update:location', location, namePOI) +} -// หาตำแหน่ง +/** function หาตำแหน่ง*/ function findNearestPlace() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( @@ -37,7 +37,10 @@ function findNearestPlace() { } } - +/** + * function หาสถานที่ที่ใกล้ที่สุด + * @param userLocation พิกัดละติจูด พิกัดลองจิจูด + */ function findNearestPlaceFromAPI(userLocation: any) { const placesService = new google.maps.places.PlacesService( document.createElement('div') @@ -55,8 +58,7 @@ function findNearestPlaceFromAPI(userLocation: any) { const place = results[0] location.value = place.name test.value = place.geometry.location - updateLocation(center.value,location.value) - + updateLocation(center.value, location.value) } else { console.error('Error fetching nearby places:', status) } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 771bfff..f217753 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,40 +1,45 @@