-
Notifications
You must be signed in to change notification settings - Fork 7
/
template-day-points.html
79 lines (68 loc) · 1.7 KB
/
template-day-points.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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title>Points by Day</title>
</head>
<body>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?libraries=visualization&sensor=false&key=AIzaSyALrS4bNPhHaZ73dACaSxD-r6oht4CX7B8">
</script>
<script>
document.body.onload = function() {
fetch("dances_locs.json", function(response) {
load_dances(JSON.parse(response));
});
};
function fetch(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState==4 && xhr.status==200) {
callback(xhr.responseText);
}
};
xhr.open("GET",url,true);
xhr.send();
}
function add_link(marker, url) {
google.maps.event.addListener(marker, 'click', function() {
window.open(url);
});
}
function load_dances(dances) {
var usa = new google.maps.LatLng(39.81,-98.56);
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: usa,
zoom: 5,
});
var day = window.location.pathname.split("-")[0].split("/")[1];
for (var i = 0 ; i < dances.length ; i++) {
var url = dances[i][0];
var name = dances[i][1];
var days = dances[i][2];
var weight = dances[i][3];
var lat = dances[i][4];
var lng = dances[i][5];
var active = dances[i][7];
if (!active) continue;
if (days.toLowerCase().search(day) < 0) {
continue;
}
var loc = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: loc,
url: url,
title: name,
map: map
});
add_link(marker, url);
}
}
</script>
<div id="map-canvas"></div>
</body> </html>