-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
288 lines (243 loc) · 6.64 KB
/
index.html
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!DOCTYPE html>
<html>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,300,400,600,700,800" rel="stylesheet" type="text/css">
<style type="text/css">
body {
font-family: 'Open Sans', sans-serif;
width: 800px;
}
.intro {
margin-top: 5px;
margin-bottom: 5px;
font-family: 'Open Sans', sans-serif;
font-size: 20px;
font-weight: 300;
}
.coord {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
}
.control {
}
.json {
font-size: 15px;
font-weight: 300;
}
a{
text-decoration: none;
}
.onleft {
position: relative;
left: 0px;
width: 30px;
}
.onright {
position: relative;
left: 60px;
width: 30px;
}
.inmiddle {
position: relative;
left: 45px;
width: 30px;
}
html, body, #map-canvas {
margin: 2px;
padding: 0px;
height: 90%;
}
</style>
<head>
<title>ARVisionMap</title>
</head>
<body>
<div class="intro">
augmented reality map
</div>
<div class="coord">
<span>latitude:</span>
<span id="lat"></span>
<span>longitude:</span>
<span id="lon"></span>
<div class="json">
<span>JSON</span>
<a href="json">location</a>
<a href="calendar">calendar</a>
</div>
</div>
<script type="text/javascript">
const step = 1e-5;
const bitnum = 5;
var lat = {{lat}};
var lon = {{lon}};
var map;
var cir;
var devices = [
['Afinia', 37.87477, -122.25848],
['Projet 3000', 37.87480, -122.25849],
['Product Photo Studio', 37.87484, -122.25851],
['VLS Laser Cutter', 37.87485, -122.25859],
['Power Electronics', 37.87479, -122.25857]
];
var bounds = [
[37.87488, -122.25851],
[37.87476, -122.25846],
[37.87474, -122.25856],
[37.87486, -122.25861]
];
document.getElementById("lat").innerHTML= lat.toFixed(bitnum);
document.getElementById("lon").innerHTML= lon.toFixed(bitnum);
function incLat() {
lat += step;
document.getElementById("lat").innerHTML=lat.toFixed(bitnum);
refresh();
}
function decLat() {
lat -= step;
document.getElementById("lat").innerHTML=lat.toFixed(bitnum);
refresh();
}
function incLon() {
lon += step;
document.getElementById("lon").innerHTML=lon.toFixed(bitnum);
refresh();
}
function decLon() {
lon -= step;
document.getElementById("lon").innerHTML=lon.toFixed(bitnum);
refresh();
}
function setLoc(lati, longi) {
lat = lati;
lon = longi;
document.getElementById("lat").innerHTML= lat.toFixed(bitnum);
document.getElementById("lon").innerHTML= lon.toFixed(bitnum);
upload();
}
function refresh() {
var curLoc = new google.maps.LatLng(lat, lon);
placeMarker(curLoc, map);
}
function upload() {
$.post("/update", {'lat': lat, 'lon': lon}, function(lat, lon) {
console.log(lat);
console.log(lon);
});
}
window.onkeydown = function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code > 40 || code < 37)
return;
if (code === 37) { // left
decLon();
}
else if (code === 38) { // up
incLat();
}
else if (code === 39) { // right
incLon();
}
else if (code === 40) { // up
decLat();
}
};
window.onkeyup = function (e) {
upload();
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
function initialize() {
var loc = new google.maps.LatLng(lat, lon);
var mapOptions = {
zoom: 20,
center: loc,
keyboardShortcuts: false
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
addCircle(loc, map);
// draw simulated boundary
new google.maps.Polygon({
map: map,
paths: [
new google.maps.LatLng(bounds[0][0], bounds[0][1]),
new google.maps.LatLng(bounds[1][0], bounds[1][1]),
new google.maps.LatLng(bounds[2][0], bounds[2][1]),
new google.maps.LatLng(bounds[3][0], bounds[3][1]),
],
strokeColor: '#2E8A5C',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#000000',
fillOpacity: 0.10,
draggable: false,
geodesic: true,
clickable: false
});
var infoWindow = new google.maps.InfoWindow();
// draw all devices on the map
for (var i = 0; i < devices.length; i++) {
var markerloc = new google.maps.LatLng(devices[i][1], devices[i][2]);
var marker = new google.maps.Marker({
position: markerloc,
icon: {
path: google.maps.SymbolPath.BACKWARD_OPEN_ARROW,
scale: 3
},
map: map,
title: devices[i][0]
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infoWindow.setContent(devices[i][0]);
infoWindow.open(map, marker);
}
})(marker, i));
}
google.maps.event.addListener(map, 'click', function(e) {
placeMarker(e.latLng, map);
});
}
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' +
'callback=initialize';
document.body.appendChild(script);
}
function addCircle(position, map) {
if (cir != undefined)
cir.setMap(null);
cir = new google.maps.Circle({
center: position,
map: map,
radius: 1,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35
});
}
function placeMarker(position, map) {
setLoc(position.lat(), position.lng());
addCircle(position, map);
//
map.panTo(position);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<hr>
<div class="control">
<button type="button" class="inmiddle" onclick="incLat();upload();">N</button>
<br>
<button type="button" class="onleft" onclick="decLon();upload();">W</button>
<button type="button" class="onright" onclick="incLon();upload();">E</button>
<br>
<button type="button" class="inmiddle" onclick="decLat();upload();">S</button>
</div>
<div id="map-canvas"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
</body>
</html>