gerson
2024-12-15 69489bc703827ae718cf194faf484ea94a3bfbd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export function getCurrentPosition() {
    const p = new Promise<GeolocationPosition | null>((resolve, reject) => {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(
                (position) => resolve(position),
                (error) => {
                    resolve(null);
                }
            );
        } else {
            console.log('Geolocation is not supported by this browser.');
            resolve(null);
        }
    });
    return p;
}