Snip2Code is shutting down.
It has been quite a ride, since 2013 when we launched our first prototype: thanks to the effort of you guys we collected more than 3 million snippets!
We are very proud to help all our users to be more efficient in their jobs, and to be the central point to share programming knowledge for everyone.
Our basic service is free, so we always survived on our own resources to give you Snip2Code.
Unfortunately, we are no more in the financial position to sustain this effort, and therefore we are announcing here our permanent shut down,
which will take place on August 1st, 2020.
Please save your private snippets using our backup function in the settings, here.
IF YOU WANT TO SAVE SNIP2CODE, PLEASE CONSIDER DOING A DONATION!
This will allow us to pay for the servers and the infrastructure. If you want to donate, Contact Us!
by
1
3
157k
1
Top 1% !
Pearl of Wisdom
Specified
Popularity: 11896th place

Published on:

No tags for this snippet yet.
LanguageHTML
LicenseMIT_X11
SourceGitHub
SourceMyGists

Simple position tracker

Simple position tracker: 
index.html
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/267379/Simple-position-tracker?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
<!Doctype html> <meta name="viewport" content="width=620" /> <title>KnD-MApPA</title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <article> <p>Finding You...: <span id="status">Checking...</span> </p> </article> <script> var map = "", marker = ""; function success2(position) { var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); marker = new google.maps.Marker({ position: latlng, map: map, title: "You are here @ " + getDateTime() + " - ( error margin: " + position.coords.accuracy + " meters )" }); }; function success(position) { var s = document.querySelector('#status'); if (s.className == 'success') { return; } s.innerHTML = "I See You!!"; s.className = 'success'; var mapcanvas = document.createElement('div'), mapcanvas.id = 'mapcanvas', w = window.innerWidth - 100, h = '360px', mapcanvas.style.height = h, mapcanvas.style.width = w, mapcanvas.style.marginLeft = 'auto', document.querySelector('article').appendChild(mapcanvas); var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude), myOptions = { zoom: 15, center: latlng, mapTypeControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL }, mapTypeId: google.maps.MapTypeId.HYBRID }; map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions), marker = new google.maps.Marker({ position: latlng, map: map, title: "You are here @ " + getDateTime() + " ( error margin: " + position.coords.accuracy + " meters )" }); }; function getDateTime() { var now = new Date(), year = now.getFullYear(), month = (now.getMonth() + 1), day = now.getDate(), hour = now.getHours(), minute = now.getMinutes(), second = now.getSeconds(); if (month.toString().length == 1) { var month = '0' + month; } if (day.toString().length == 1) { var day = '0' + day; } if (hour.toString().length == 1) { var hour = '0' + hour; } if (minute.toString().length == 1) { var minute = '0' + minute; } if (second.toString().length == 1) { var second = '0' + second; } var dateTime = month + '/' + day + '/' + year + ' ' + hour + ':' + minute + ':' + second; return dateTime; }; function error(msg) { var s = document.querySelector('#status'); s.innerHTML = typeof msg == 'string' ? msg : "failed"; s.className = 'fail'; }; var opts = { enableHighAccuracy: true }, wtch = ""; if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(success, error); wtch = navigator.geolocation.watchPosition(success2, error, opts) } else { error('not supported'); } window.onbeforeunload(function(e) { navigator.geolocation.clearWatch(wtch); }); </script>
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus