Created
September 13, 2023 14:09
-
-
Save jgphilpott/cba08445a1a905a0f5a92fe056cf9e22 to your computer and use it in GitHub Desktop.
A helpful interface for the navigator geolocation object.
This file contains hidden or 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
# Credit: https://www.w3schools.com/js/js_api_geolocation.asp | |
class Geo | |
constructor: -> | |
@location = navigator.geolocation | |
position: (callback = this.log) -> | |
return this.location.getCurrentPosition callback | |
log: (data) -> | |
console.log data |
This file contains hidden or 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
// Credit: https://www.w3schools.com/js/js_api_geolocation.asp | |
var Geo; | |
Geo = class Geo { | |
constructor() { | |
this.location = navigator.geolocation; | |
} | |
position(callback = this.log) { | |
return this.location.getCurrentPosition(callback); | |
} | |
log(data) { | |
return console.log(data); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment