Skip to content

Instantly share code, notes, and snippets.

@dellisd
Created December 3, 2022 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dellisd/ce3b8376d911fc7f0a148ceb6a13a24a to your computer and use it in GitHub Desktop.
Save dellisd/ce3b8376d911fc7f0a148ceb6a13a24a to your computer and use it in GitHub Desktop.
external class GeolocationCoordinates {
val latitude: Double
val longitude: Double
val altitutde: Double
val accuracy: Double
val altitudeAccuracy: Double
val heading: Double
val speed: Double
}
external class GeolocationPosition {
val coords: GeolocationCoordinates
val timestamp: Double
}
external class GeolocationPositionError {
val code: Int
val message: String
}
external class GeolocationOptions {
val maximumAge: Int
val timeout: Int
val enableHighAccuracy: Boolean
}
external class Geolocation {
fun getCurrentPosition(success: (GeolocationCoordinates) -> Unit, error: (GeolocationPositionError) -> Unit = {}, options: GeolocationOptions? = null)
fun watchPosition(success: (GeolocationCoordinates) -> Unit, error: (GeolocationPositionError) -> Unit = {}, options: GeolocationOptions? = null): Int
fun clearWatch(id: Int)
}
val Navigator.geolocation get() = js("window.navigator.geolocation").unsafeCast<Geolocation>()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment