location

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package location tells where the device is, on phones and tablets: Core Location on iOS, and LocationManager on Android, without Google's services. Importing it adds the permissions it needs to the app, with a usage description on iOS that ios.infoPlist in the app's configuration replaces:

"NSLocationWhenInUseUsageDescription": "Shows nearby stores."

Elsewhere its functions report errors.ErrUnsupported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestPermission

func RequestPermission(ctx context.Context) (bool, error)

RequestPermission asks the user to let the app know where the device is, the first time, and reports whether it may. Call it off the main goroutine, as it waits for the user.

func Watch

func Watch(ctx context.Context, fn func(Fix)) (stop func(), err error)

Watch calls fn on the main thread as the device moves, until stop is called.

Types

type Fix

type Fix struct {
	// Latitude and Longitude are in degrees.
	Latitude, Longitude float64
	// Altitude is in meters above sea level, Speed in meters a second, and
	// Heading in degrees clockwise from north; negative where not known.
	Altitude, Speed, Heading float64
	// Accuracy is how far off it may be, in meters.
	Accuracy float64
	// Time is when it was measured.
	Time time.Time
}

Fix is a place the device was at.

func Current

func Current(ctx context.Context) (Fix, error)

Current finds where the device is now, asking for permission if it must.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL