Created
October 22, 2012 07:38
-
-
Save jamesmills/3930151 to your computer and use it in GitHub Desktop.
geolocation
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
<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