location.LocationHeading
Which way the device points, for a compass or for turning a map with the user.
Usage
Observe compass readings and stop when the screen unmounts.
This type is used by 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>;
}Type declaration
export type LocationHeading = Heading;Members 3
| Name | Type | Required | Description |
|---|---|---|---|
trueHeading | number | Yes | Degrees from true north; null until the platform knows where the device is. |
magHeading | number | Yes | Degrees from magnetic north. |
accuracy | number | Yes | iOS: the error in degrees. Android: the compass's calibration, 0 (none) to 3 (high). |
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.