| | |
| | | import { currentPosition } from '../stores/chatRoom'; |
| | | |
| | | export function getCurrentPosition() { |
| | | if (currentPosition.value) { |
| | | return Promise.resolve(currentPosition.value); |
| | | } |
| | | const p = new Promise<{ |
| | | latitude: number; |
| | | longitude: number; |
| | |
| | | const geoLocation = window.plus ? plus.geolocation : navigator.geolocation; |
| | | if (geoLocation) { |
| | | geoLocation.getCurrentPosition( |
| | | (position) => |
| | | (position) => { |
| | | const { latitude, longitude } = position.coords; |
| | | currentPosition.value = { |
| | | latitude, |
| | | longitude, |
| | | }; |
| | | resolve({ |
| | | latitude: position.coords.latitude, |
| | | longitude: position.coords.longitude, |
| | | }), |
| | | latitude, |
| | | longitude, |
| | | }); |
| | | }, |
| | | |
| | | (error) => { |
| | | resolve(null); |
| | | } |