-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.html
130 lines (118 loc) · 3.24 KB
/
debug.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Daily Walk Bot Results</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDJAUwP5BmrJFVolo9T7OQsf_CusoHODIo&libraries=geometry">
</script>
</head>
<body>
<div id="map"></div>
<script>
var lineSymbol = {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW
};
var circleSymbol = {
path: google.maps.SymbolPath.CIRCLE
};
function decode(path){
return google.maps.geometry.encoding.decodePath(path);
}
var num = location.search.split('num=')[1] ? location.search.split('num=')[1] : 0;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "http://jlareau.club.cc.cmu.edu/walker/debug_file.json", false);
xmlHttp.send( null );
data = JSON.parse(xmlHttp.responseText)[num];
function addMarker(location, map) {
var marker = new google.maps.Marker({
position: location,
map: map
});
}
function addPolyline(line, map, percentage, color) {
if(!percentage){
var flightPath = new google.maps.Polyline({
path: line,
geodesic: true,
strokeColor: color,
strokeOpacity: 1.0,
strokeWeight: 2,
map: map,
icons: [{
icon: circleSymbol
}],
});
} else {
var flightPath = new google.maps.Polyline({
path: line,
geodesic: true,
strokeColor: color,
strokeOpacity: 1.0,
strokeWeight: 2,
map: map,
icons: [{
icon: lineSymbol,
offset: percentage + '%'
},
{
icon: circleSymbol
}],
});
}
}
function addRectangle(bounds, map) {
var rectangle = new google.maps.Rectangle({
strokeColor: '#0000FF',
strokeOpacity: 0.8,
strokeWeight: 2,
fillOpacity: 0.0,
map: map,
bounds: bounds
});
}
encodedPath = data['overview'];
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: {lat: data['start'][0], lng: data['start'][1]}
});
var flightPlanCoordinates = [
{lat: data['last'][0], lng: data['last'][1]},
{lat: data['start'][0], lng: data['start'][1]}
];
var bounds = {
north: data['start'][0] + 0.1,
south: data['start'][0] - 0.1,
east: data['start'][1] + 0.16,
west: data['start'][1] - 0.04
}
addPolyline(decode(encodedPath), map, null, "#FF0000");
addPolyline(flightPlanCoordinates, map, null, "#00FF00");
for(i = 0; i < data['path_polylines'].length; i++){
if(i == data['path_polylines'].length -1){
addPolyline(decode(data['path_polylines'][i]), map, data['percentage']*100, '#0000FF');
} else {
addPolyline(decode(data['path_polylines'][i]), map, null, '#0000FF');
}
}
addRectangle(bounds, map);
addMarker({lat: data['last'][0], lng: data['last'][1]}, map);
addMarker({lat: data['start'][0], lng: data['start'][1]}, map);
addMarker({lat: data['end'][0], lng: data['end'][1]}, map);
}
initMap();
</script>
</body>
</html>