LocationHeading
Which way the device points, for a compass or for turning a map with the user.
Utilisation
Observe compass readings and stop when the screen unmounts.
Ce type est utilisé par location.watchHeading
// Observe compass readings and stop when the screen unmounts.
import { Text, onMount, signal, location, type EventSubscription } from 'kuito';
export function Compass() {
const heading = signal('Waiting for compass');
onMount(() => {
let disposed = false;
let subscription: EventSubscription | undefined;
void location
.watchHeading((value) => {
heading.value = JSON.stringify(value);
})
.then((value) => {
if (disposed) value.remove();
else subscription = value;
})
.catch((error) => {
heading.value = String(error);
});
return () => {
disposed = true;
subscription?.remove();
};
});
return <Text>{heading.value}</Text>;
}Déclaration du type
export type LocationHeading = Heading;Membres 3
| Nom | Type | Requis | Description |
|---|---|---|---|
trueHeading | number | Oui | Degrees from true north; null until the platform knows where the device is. |
magHeading | number | Oui | Degrees from magnetic north. |
accuracy | number | Oui | iOS: the error in degrees. Android: the compass's calibration, 0 (none) to 3 (high). |
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.