Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(geolocation): add geolocation module
- Loading branch information
Garrett Downs
committed
Mar 26, 2022
1 parent
1cf31a1
commit 69b954d
Showing
7 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class PermissionError extends Error { | ||
name: string = 'PermissionError'; | ||
|
||
constructor(message?: string) { | ||
super(message); | ||
|
||
if (message) { | ||
this.message = message; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './PermissionError'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { App } from './modules/app'; | ||
import { Battery } from './modules/battery'; | ||
import { FileStorage } from './modules/fileStorage'; | ||
import { Geolocation } from './modules/geolocation'; | ||
import { LocalStorage } from './modules/localStorage'; | ||
import { Volume } from './modules/volume'; | ||
|
||
export class KaiOS { | ||
static Volume = Volume; | ||
static LocalStorage = LocalStorage; | ||
static FileStorage = FileStorage; | ||
export * from './modules/app'; | ||
export * from './modules/battery'; | ||
export * from './modules/fileStorage'; | ||
export * from './modules/geolocation'; | ||
export * from './modules/localStorage'; | ||
export * from './modules/volume'; | ||
|
||
export default class KaiOS { | ||
static App = App; | ||
static Battery = Battery; | ||
static FileStorage = FileStorage; | ||
static Geolocation = Geolocation; | ||
static LocalStorage = LocalStorage; | ||
static Volume = Volume; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type Location = GeolocationPosition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Navigator } from './navigator'; | ||
|
||
type GetCurrentOptions = { | ||
maximumAge?: number; | ||
timeout?: number; | ||
enableHighAccuracy?: boolean; | ||
}; | ||
|
||
export class Geolocation { | ||
getCurrent(options?: GetCurrentOptions): Promise<Location> { | ||
return new Promise((resolve, reject) => { | ||
Navigator.navigator.geolocation.getCurrentPosition( | ||
(position: Location) => resolve(position), | ||
(err: GeolocationPositionError) => reject(err), | ||
options | ||
); | ||
}); | ||
} | ||
} |