check poi, latitude, longitude and alert message befor post to api
This commit is contained in:
parent
cbfb7cdfdd
commit
cfaf841119
2 changed files with 11 additions and 5 deletions
|
|
@ -210,10 +210,18 @@ const requestLocationPermission = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.geolocation.getCurrentPosition(
|
navigator.geolocation.getCurrentPosition(
|
||||||
() => {
|
(position) => {
|
||||||
// Permission granted
|
// Permission granted
|
||||||
locationGranted.value = true
|
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
|
// Center map on user's location if map is initialized
|
||||||
initializeMap()
|
initializeMap()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,7 @@ const timeChickin = ref<string>('') //เวลาเข้างาน,เว
|
||||||
|
|
||||||
/** function ยืนยันการลงเวลาเข้า - ออก*/
|
/** function ยืนยันการลงเวลาเข้า - ออก*/
|
||||||
async function confirm() {
|
async function confirm() {
|
||||||
if (!formLocation.POI || formLocation.POI === '') {
|
if (!formLocation.POI || !formLocation.lat || !formLocation.lng) {
|
||||||
mapRef.value?.requestLocationPermission()
|
mapRef.value?.requestLocationPermission()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -354,9 +354,7 @@ async function confirm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCheck() {
|
async function getCheck() {
|
||||||
console.log('getCheck')
|
if (!formLocation.POI || !formLocation.lat || !formLocation.lng) {
|
||||||
|
|
||||||
if (!formLocation.POI || formLocation.POI === '') {
|
|
||||||
mapRef.value?.requestLocationPermission()
|
mapRef.value?.requestLocationPermission()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue