Skip to content

Instantly share code, notes, and snippets.

@jgphilpott
Created September 13, 2023 14:09
Show Gist options
  • Save jgphilpott/cba08445a1a905a0f5a92fe056cf9e22 to your computer and use it in GitHub Desktop.
Save jgphilpott/cba08445a1a905a0f5a92fe056cf9e22 to your computer and use it in GitHub Desktop.
A helpful interface for the navigator geolocation object.
# 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
// 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