Commit 3dc61399c268fbb5b29ef38c51da4440292694c3
static
Dominic Tarr committed on 7/8/2017, 1:36:15 AMParent: 6ad452e049e6b44d559888128267bb109a3f1aad
Files changed
index.html | changed |
index.html | |||
---|---|---|---|
@@ -5,8 +5,9 @@ | |||
5 | 5 … | <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> | |
6 | 6 … | <meta charset=utf-8></head> | |
7 | 7 … | <body></body> | |
8 | 8 … | <script> | |
9 … | +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
9 | 10 … | var pre = document.createElement('pre') | |
10 | 11 … | document.body.appendChild(pre) | |
11 | 12 … | ||
12 | 13 … | function flatten (p) { | |
@@ -18,12 +19,29 @@ | |||
18 | 19 … | o[k] = p[k] | |
19 | 20 … | return o | |
20 | 21 … | } | |
21 | 22 … | ||
23 … | +var positions = [] | ||
24 … | + | ||
25 … | +pre.textContent = 'waiting for position...' | ||
26 … | + | ||
22 | 27 … | navigator.geolocation.watchPosition(function (e) { | |
23 | 28 … | console.log(e.coords, e.timestamp) | |
24 | - pre.textContent = JSON.stringify(flatten(e), null, 2) | ||
29 … | + position.push(flatten(e)) | ||
30 … | + //keep just one minute's worth of locations. | ||
31 … | + if(e.timestamp < Date.now() - 60e3) // one minute | ||
32 … | + positions.shift() | ||
33 … | + | ||
34 … | + var movement = position.map(function (_e) { | ||
35 … | + return { | ||
36 … | + distance: GreatCircle.distance(_e.latitude, _e.longitude, e.latitude, e.longitude, 'NM'), | ||
37 … | + heading: GreatCircle.bearing(_e.latitude, _e.longitude, e.latitude, e.longitude) | ||
38 … | + } | ||
39 … | + }) | ||
40 … | + | ||
41 … | + pre.textContent = JSON.stringify({current: flatten(e), movement: movement}, null, 2) | ||
25 | 42 … | }) | |
26 | 43 … | ||
27 | 44 … | ||
45 … | +},{}]},{},[1]); | ||
28 | 46 … | </script> | |
29 | 47 … | </html> |
Built with git-ssb-web