Syamsoul Azrien
Syamsoul Azrien

Reputation: 2742

Ionic/Capacitor - GeoLocation WatchPosition timeout

There are two question I wanna ask.

  1. The value for timeout option is in seconds or miliseconds?
  2. Where to execute code if the timeout reached? (do something after timeout)

.

let wait: string;
wait = Plugins.Geolocation.watchPosition({
    enableHighAccuracy: true,
    timeout:5 // i dont if this is seconds or miliseconds
}, (position, err) => {
    // do something

    Plugins.Geolocation.clearWatch({
            id: wait
    });
});

// i want to detect if the location still doesnt detect, and it already time-out, i want to do something

The documention is too simple. Very hard to understand. https://capacitor.ionicframework.com/docs/apis/geolocation/

Upvotes: 2

Views: 1528

Answers (1)

Manuel
Manuel

Reputation: 443

The timeout is defined in miliseconds based on the assumption, that the Capacitor API is probably equal to the Web Geolocation API. If the timeout is reached and watchPosition() couldn't get a position, you should be able to check your err value.

Upvotes: 1

Related Questions