-
-
Save Thorsson/191934 to your computer and use it in GitHub Desktop.
This file contains 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 geo = navigator.geolocation || (window.google && google.gears && google.gears.factory.create('beta.geolocation')); | |
if (geo) geo.getCurrentPosition(displayLocation, handleError); | |
function displayLocation(position) { | |
position.coords.latitude; | |
position.coords.longitude; | |
position.coords.accuracy; | |
} | |
function handleError(error) { | |
switch (error.code) { | |
case error.PERMISSION_DENIED: | |
alert('Sorry. Permission to find your location has been denied.'); | |
break; | |
case error.POSITION_UNAVAILABLE: | |
alert('Sorry. Position unavailable.'); | |
break; | |
default: | |
alert('Error code: ' + error.code); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment