by
9
5
4,201
0
Top 1% !
Popular
Famous
Nice
Specified
Popularity: 1916th place
Created
Modified Jul 10, 2014
This snippet is Public
No tags for this snippet yet.
LanguageJavaScript
LicenseMIT_X11
SourceGitHub

geo locator module

geo locator module: 
GTRX.js
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/90658/geo-locator-module?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
// GTRX geolocator function GTRX() { function startG() { if (window.navigator.geolocation) { var trxLST = [], pID = "", cnt = 0, ipAddrs = ""; var options = { allowhighaccuracy: true, timeout: 50000, maximumage: 6000 }; var errHndlr = function(err) { if (err.code == 1) { console.log("Error: Access is denied!"); } else if (err.code == 2) { console.log("Error: Position unavailable!"); } }; window.onbeforeunload = function(evt) { navigator.geolocation.clearWatch(pID); window.localStorage.clear(); clearInterval(iID); trax = JSON.stringify({ "state": "END-TRAK" }); $.getJSON("https://script.google.com/macros/s/AKfycbyOAEFG8LufiDKjoRjlRiI0U27K4WQqN1G-6jMR19GMIVL-Bc8/exec?", { "p": trax, "prefix": "?" }, function(response) { console.log("END-TRACE-SUMMARY: " + JSON.stringify(response)); trxLST.length = 0; cnt = 0; }); }; pID = window.navigator.geolocation.watchPosition(keepIt, errHndlr, options); var keepIT = function(position) { cnt++; trxLST.push(position); var p = JSON.stringify(position); console.log("SUMMARY-" + cnt + ": " + p); if ((cnt % 10) === 0) { trax = JSON.stringify({ "TRaX": trxLST }); var storPrev = window.localStorage.getItem("GEOsTORe"); window.localStorage.setItem("GEOsTORe", storPrev + ", " + trax); $.getJSON("https://script.google.com/macros/s/AKfycbyOAEFG8LufiDKjoRjlRiI0U27K4WQqN1G-6jMR19GMIVL-Bc8/exec?", { "p": trax, "prefix": "?" }, function(response) { console.log("SUMMARY-" + cnt + ": " + JSON.stringify(response)); }); trxLST.length = 0; } else { console.log("Error: Position unavailable!"); } }; } else { console.log("Geolocation is Not Supported"); } } startG(); } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus