Created
November 5, 2014 17:40
-
-
Save andredelgado/32109d83422b3a645e63 to your computer and use it in GitHub Desktop.
get 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
var lat = 0; | |
var longi = 0; | |
function getLocation() { | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(showPosition); | |
} else { | |
console.log("Geolocation is not supported by this browser."); | |
} | |
} | |
function showPosition(position) { | |
lat = position.coords.latitude; | |
longi = position.coords.longitude; | |
} | |
getLocation(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment