Last active
February 16, 2020 22:12
-
-
Save ChaseH88/4a2f49f3cc9832aab398db2b2302f56f to your computer and use it in GitHub Desktop.
Get Current Location
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
| /** | |
| * Get the current location inside of the | |
| * browser window. Simply run the script, | |
| * then enter the 'coordinates' variable | |
| * to return your current location. | |
| */ | |
| const geo = navigator.geolocation; | |
| let coordinates = null; | |
| const showLocation = ({ coords }) => { | |
| coordinates = { | |
| lat: coords.latitude, | |
| lon: coords.longitude | |
| } | |
| } | |
| geo.getCurrentPosition(showLocation, (err) => new Error(err), { | |
| enableHighAccuracy: true, | |
| timeout: 5000, | |
| maximumAge: 0 | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment