From 9f6fffd73c9a05202bcf613f31924ee6ddd846e4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 16 Nov 2023 09:43:44 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20code=20?= =?UTF-8?q?=20=E0=B8=A5=E0=B8=87=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2?= =?UTF-8?q?=E0=B9=80=E0=B8=82=E0=B9=89=E0=B8=B2-=E0=B8=AD=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B8=87=E0=B8=B2=E0=B8=99=20(USER)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MapCheckin.vue | 16 ++-- src/views/HomeView.vue | 156 ++++++++++++++++++---------------- 2 files changed, 94 insertions(+), 78 deletions(-) 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 @@