Created
July 31, 2012 18:33
geo-test
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
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
</head> | |
<body> | |
<input type="button" value="Show position" onclick="show()"> | |
<div id="data"> | |
</data> | |
<script language="javascript"> | |
function showPos(position) { | |
var htmlStr = '<p>'+ 'Latitude: ' + position.coords.latitude + '<br />' | |
+ 'Longitude: ' + position.coords.longitude + '<br />' | |
+ '</p>'; | |
document.getElementById('data').innerHTML = htmlStr; | |
} | |
function error() { | |
alert('Could not get your location.'); | |
} | |
function show(){ | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(showPos, error, {timeout:20000}); | |
//navigator.geolocation.watchPosition(showPos, error, {enableHighAccuracy:true, //maximumAge:30000, timeout:20000}); | |
} else { | |
alert('No support for geolocation') | |
} | |
} | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment