Created
February 8, 2012 00:59
-
-
Save mattgaidica/1763696 to your computer and use it in GitHub Desktop.
Simple Geolocation for iPhone
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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>GEO</title> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<!-- Le HTML5 shim, for IE6-8 support of HTML elements --> | |
<!--[if lt IE 9]> | |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<!-- Le styles --> | |
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet"> | |
<style> | |
body { | |
padding-top:20px; | |
} | |
</style> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script> | |
var count = 0; | |
$(function() { | |
if(!!navigator.geolocation) { | |
navigator.geolocation.watchPosition(geo_success, geo_error, {enableHighAccuracy:true, maximumAge:30000, timeout:27000}); | |
} else { | |
alert('Geo is not supported.'); | |
} | |
}); | |
function geo_success(position) { | |
count = count + 1; | |
$('#count').text(count.toString()); | |
$('#latitude').text(position.coords.latitude.toString()); | |
$('#longitude').text(position.coords.longitude.toString()); | |
$('#accuracy').text(position.coords.accuracy.toString()); | |
} | |
function geo_error(error){ | |
alert('Error!'); | |
} | |
</script> | |
</head> | |
<body> | |
<div class="container-fluid"> | |
<div class="row-fluid"> | |
<div class="span12"> | |
<div class="well"> | |
<div>Count: <span id="count"></span></div> | |
<div>Latitude: <span id="latitude"></span></div> | |
<div>Longitude: <span id="longitude"></span></div> | |
<div>Accuracy: <span id="accuracy"></span></div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment