geolocation
by dirkk0
HTML
<div id="lat">lat:</div>
<div id="lon">lon:</div>
<div id="acc">acc:</div>
<div id="alt">alt:</div>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23915674-6']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
setTimeout( function()
{
document.body.insertAdjacentHTML(
'afterBegin',
'<a href="http://thinkingstiff.com" '
+ 'target="_top" '
+ 'onmouseover="this.style.opacity=\'.95\'" '
+ 'onmouseout="this.style.opacity=\'1\'" '
+ 'style="'
+ 'background-color: black;'
+ 'background-image: linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
+ 'background-image: -webkit-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
+ 'background-image: -moz-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
+ 'background-image: -o-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
+ 'background-image: -ms-linear-gradient( top, rgba( 255, 255, 255, .3), rgba( 255, 255, 255, 0) );'
+ 'border: 1px solid black;'
+ 'border-radius: 2px;'
+ 'bottom: 0;'
+ 'color: white;'
+ 'display: block;'
+ 'font-family: Helvetica, Verdana, Tahoma;'
+ 'opacity: 1;'
+ 'padding: 4px 8px;'
+ 'position: absolute;'
+ 'right: 0;'
+ 'text-decoration: none;'
+ 'text-shadow: -1px -1px black;'
+ 'z-index: 999;'
...
JavaScript
function doGeo( position )
{
$( "#lat" ).html("lat: " + position.coords.latitude );
$( "#lon" ).html("lon: " + position.coords.longitude );
$( "#acc" ).html("acc: " + position.coords.accuracy );
$( "#alt" ).html("alt: " + position.coords.speed );
}
function lost()
{
};
navigator.geolocation.watchPosition( doGeo, lost, {maximumAge:0,enableHighAccuracy:true} );