system-geolocation
v0.1.2
Published
System location for android
Readme
system-geolocation
System location for android
Install
npm install system-geolocation
npx cap syncAPI
getCurrentPosition(...)watchPosition(...)watchGPS(...)clearWatch(...)clearGPSWatch(...)checkPermissions()requestPermissions(...)- Interfaces
- Type Aliases
getCurrentPosition(...)
getCurrentPosition(options?: PositionOptions | undefined) => Promise<Position>Get the current GPS location of the device
| Param | Type |
| ------------- | ----------------------------------------------------------- |
| options | PositionOptions |
Returns: Promise<Position>
Since: 1.0.0
watchPosition(...)
watchPosition(options: PositionOptions, callback: WatchPositionCallback) => Promise<CallbackID>Set up a watch for location changes. Note that watching for location changes can consume a large amount of energy. Be smart about listening only when you need to.
| Param | Type |
| -------------- | ----------------------------------------------------------------------- |
| options | PositionOptions |
| callback | WatchPositionCallback |
Returns: Promise<string>
Since: 1.0.0
watchGPS(...)
watchGPS(callback: WatchGPSResultCallback) => Promise<CallbackID>Set up a watch for gps changes. Note that watching for gps changes can consume a large amount of energy. Be smart about listening only when you need to.
| Param | Type |
| -------------- | ------------------------------------------------------------------------- |
| callback | WatchGPSResultCallback |
Returns: Promise<string>
Since: 1.0.0
clearWatch(...)
clearWatch(options: ClearWatchOptions) => Promise<void>Clear a given location watch
| Param | Type |
| ------------- | --------------------------------------------------------------- |
| options | ClearWatchOptions |
Since: 1.0.0
clearGPSWatch(...)
clearGPSWatch(options: ClearGPSWatchOptions) => Promise<void>Clear a given gps watch
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options | ClearGPSWatchOptions |
Since: 1.0.0
checkPermissions()
checkPermissions() => Promise<PermissionStatus>Check location permissions. Will throw if system location services are disabled.
Returns: Promise<PermissionStatus>
Since: 1.0.0
requestPermissions(...)
requestPermissions(permissions?: GeolocationPluginPermissions | undefined) => Promise<PermissionStatus>Request location permissions. Will throw if system location services are disabled.
| Param | Type |
| ----------------- | ------------------------------------------------------------------------------------- |
| permissions | GeolocationPluginPermissions |
Returns: Promise<PermissionStatus>
Since: 1.0.0
Interfaces
Position
| Prop | Type | Description | Since |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----- |
| timestamp | number | Creation timestamp for coords | 1.0.0 |
| coords | { latitude: number; longitude: number; accuracy: number; altitudeAccuracy: number | null; altitude: number | null; speed: number | null; heading: number | null; } | The GPS coordinates along with the accuracy of the data | 1.0.0 |
PositionOptions
| Prop | Type | Description | Default | Since |
| ------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
| enableHighAccuracy | boolean | High accuracy mode (such as GPS, if available) On Android 12+ devices it will be ignored if users didn't grant ACCESS_FINE_LOCATION permissions (can be checked with location alias). | false | 1.0.0 |
| timeout | number | The maximum wait time in milliseconds for location updates. In Android, since version 4.0.0 of the plugin, timeout gets ignored for getCurrentPosition. | 10000 | 1.0.0 |
| maximumAge | number | The maximum age in milliseconds of a possible cached position that is acceptable to return | 0 | 1.0.0 |
GPSInfo
| Prop | Type | Description | Since |
| --------------- | ------------------- | --------------------------------- | ----- |
| gps | string | GPS info string | 1.0.0 |
| timestamp | number | The GPS timestamp in milliseconds | 1.0.0 |
ClearWatchOptions
| Prop | Type |
| -------- | ------------------------------------------------- |
| id | CallbackID |
ClearGPSWatchOptions
| Prop | Type |
| -------- | ------------------------------------------------- |
| id | CallbackID |
PermissionStatus
| Prop | Type | Description | Since |
| -------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| location | PermissionState | Permission state for location alias. On Android it requests/checks both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions. On iOS and web it requests/checks location permission. | 1.0.0 |
| coarseLocation | PermissionState | Permission state for coarseLocation alias. On Android it requests/checks ACCESS_COARSE_LOCATION. On Android 12+, users can choose between Approximate location (ACCESS_COARSE_LOCATION) or Precise location (ACCESS_FINE_LOCATION), so this alias can be used if the app doesn't need high accuracy. On iOS and web it will have the same value as location alias. | 1.2.0 |
GeolocationPluginPermissions
| Prop | Type |
| ----------------- | ---------------------------------------- |
| permissions | GeolocationPermissionType[] |
Type Aliases
WatchPositionCallback
(position: Position | null, err?: any): void
CallbackID
string
WatchGPSResultCallback
(gps: GPSInfo | null, err?: any): void
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
GeolocationPermissionType
'location' | 'coarseLocation'
