-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.html
82 lines (63 loc) · 2.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
<style>
html,
body,
#map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key={YOUR API KEY}"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<body>
<div id="map-canvas"></div>
<script>
window.onload = function() {
var request = new XMLHttpRequest();
request.open('GET', '/path.json', true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var point = {};
point = JSON.parse(request.responseText);
var lineCoordinatesArray = [];
var markers = [];
var g_point=[0,0];
for (var i = 0; i < point.length; i++) {
temp={lat:parseFloat(point[i].lat),lng:parseFloat(point[i].lng)};
g_point[0]=g_point[0]+temp.lat/point.length;
g_point[1]=g_point[1]+temp.lng/point.length;
addMarkerWithTimeout(temp, i * 70);
}
map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 16,
center: {
lat: g_point[0],
lng: g_point[1],
alt: 100
}
});
function addMarkerWithTimeout(position, timeout) {
window.setTimeout(function() {
markers.push(new google.maps.Marker({
position: position,
map: map,
animation: google.maps.Animation.DROP
}));
lineCoordinatesArray.push(position);
var lineCoordinatesPath = new google.maps.Polyline({
path: lineCoordinatesArray,
geodesic: true,
strokeColor: '#2E10FF',
strokeOpacity: 1.0,
strokeWeight: 2
});
lineCoordinatesPath.setMap(map);
}, timeout);
}
}
};
request.send();
}
</script>
</body>