location.LocationHeading
Which way the device points, for a compass or for turning a map with the user.
Utilização
Observe compass readings and stop when the screen unmounts.
Este tipo é usado por 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>;
}Declaração do tipo
export type LocationHeading = Heading;Membros 3
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
trueHeading | number | Sim | Degrees from true north; null until the platform knows where the device is. |
magHeading | number | Sim | Degrees from magnetic north. |
accuracy | number | Sim | iOS: the error in degrees. Android: the compass's calibration, 0 (none) to 3 (high). |
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.