LocationHeading
Which way the device points, for a compass or for turning a map with the user.
Verwendung
Observe compass readings and stop when the screen unmounts.
Dieser Typ wird verwendet von 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>;
}Typdeklaration
export type LocationHeading = Heading;Mitglieder 3
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
trueHeading | number | Ja | Degrees from true north; null until the platform knows where the device is. |
magHeading | number | Ja | Degrees from magnetic north. |
accuracy | number | Ja | iOS: the error in degrees. Android: the compass's calibration, 0 (none) to 3 (high). |
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.