-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouteTest.html
More file actions
108 lines (95 loc) · 3.25 KB
/
Copy pathrouteTest.html
File metadata and controls
108 lines (95 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<meta name="theme-color" content="#16191C">
<style>
body {
background: #16191C;
font-family: 'Montserrat', sans-serif;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
not supported by any browser */
cursor: default;
overflow: hidden;
}
ol {
color: #efefef;
font-size: 200%;
position: absolute;
width: 100%;
left: 0%;
top: 0%;
height: 90%;
padding: 0% 10%;
overflow-y: scroll;
background: #FFFFFF;
}
#start {
font-family: 'Montserrat', sans-serif;
position: absolute;
left: 0%;
bottom: 0%;
width: 100%;
height: 10%;
cursor: pointer;
background: #4CAF50;
color: #B3E5FC;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
transition: all ease 0.3s;
text-align: center;
font-size: 300%;
line-height: 60%;
}
#start:active {
opacity: 0.9;
}
</style>
<script>
var lastLocation;
var isWatchingPosition = false;
function geoSucces(position) {
$.getJSON('https://maps.googleapis.com/maps/api/geocode/json?address='+ position.coords.latitude +","+ position.coords.longitude +'&key=AIzaSyA_uqQ2c-rh0mdrUtveNjJTPdoSNSKRbCo', function(data) {
var obj = JSON.stringify(data, null, 2)
var gArr = $.parseJSON(obj)
if (lastLocation == null) {
document.getElementsByTagName('ol')[0].innerHTML += "<li>" + gArr.results[0].formatted_address + "</li>"
lastLocation = gArr.results[0].formatted_address
} else {
if (gArr.results[0].formatted_address != lastLocation && isWatchingPosition == true) {
document.getElementsByTagName('ol')[0].innerHTML += "<li>" + gArr.results[0].formatted_address + "</li>"
lastLocation = gArr.results[0].formatted_address
}
}
})
}
function geoError() {
}
function startStop() {
if (!isWatchingPosition) {
isWatchingPosition = true
var wpid = navigator.geolocation.watchPosition(geoSucces, geoError, {enableHighAccuracy:true,maximumAge:30000,timeout:27000})
document.getElementById('start').style.background = "#F44336"
document.getElementById('start').innerHTML = "Stop"
} else {
isWatchingPosition = false
navigator.geolocation.clearWatch(wpid)
document.getElementById('start').style.background = "#4CAF50"
document.getElementById('start').innerHTML = "Start"
}
}
</script>
</head>
<body>
<ol>
<i><small>Gemaakt door sdw7020 \_(ツ)_/¯</small></i>
<h1>Route:</h1>
</ol>
<div onclick="startStop()" id="start">Start</div>
</body>
</html>