From cfaf84111936be375ffbb6aa5f42f141805b7270 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 13 Jun 2025 12:28:48 +0700 Subject: [PATCH] check poi, latitude, longitude and alert message befor post to api --- src/components/AscGISMap.vue | 10 +++++++++- src/views/HomeView.vue | 6 ++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/AscGISMap.vue b/src/components/AscGISMap.vue index 45b83d1..b32e32a 100644 --- a/src/components/AscGISMap.vue +++ b/src/components/AscGISMap.vue @@ -210,10 +210,18 @@ const requestLocationPermission = () => { } navigator.geolocation.getCurrentPosition( - () => { + (position) => { // Permission granted locationGranted.value = true + const { latitude, longitude } = position.coords + // console.log('Current position:', latitude, longitude) + + if (!latitude || !longitude) { + messageError($q, '', 'ไม่สามารถระบุตำแหน่งปัจจุบันได้') + return + } + // Center map on user's location if map is initialized initializeMap() }, diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 2fc743e..1ca70de 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -311,7 +311,7 @@ const timeChickin = ref('') //เวลาเข้างาน,เว /** function ยืนยันการลงเวลาเข้า - ออก*/ async function confirm() { - if (!formLocation.POI || formLocation.POI === '') { + if (!formLocation.POI || !formLocation.lat || !formLocation.lng) { mapRef.value?.requestLocationPermission() return } @@ -354,9 +354,7 @@ async function confirm() { } async function getCheck() { - console.log('getCheck') - - if (!formLocation.POI || formLocation.POI === '') { + if (!formLocation.POI || !formLocation.lat || !formLocation.lng) { mapRef.value?.requestLocationPermission() return }