Skip to content

Instantly share code, notes, and snippets.

@jamesmills
Created October 22, 2012 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmills/3930151 to your computer and use it in GitHub Desktop.
Save jamesmills/3930151 to your computer and use it in GitHub Desktop.
geolocation
<script type="text/javascript" charset="utf-8">
<!--
function findLocation()
{
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
}
function foundLocation(position)
{
var lat = position.coords.latitude;
var lng = position.coords.longitude;
//alert('Found location: ' + lat + ', ' + lng);
window.location = "http://dev.domain.com/home?lat=" + lat + "&lng=" + lng;
}
function noLocation()
{
alert('Could not find location');
window.location = "http://dev.domain.com/location";
}
findLocation();
//-->
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment