-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
66 lines (63 loc) · 2.74 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
<!DOCTYPE html>
<html>
<head>
<title>Mountain View, CA – Map of active construction projects</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<a href="https://github.com/vgrichina/mtv-projects"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/superagent/3.5.0/superagent.min.js"></script>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 37.3860517, lng: -122.0838511 },
zoom: 13
});
superagent.get("data/projects.json").end(function(e, res) {
var projects = res.body;
var currentWindow = null;
projects.forEach(function(p) {
if (!p.location) {
return;
}
contentHtml = "<h3>" + p.title + "</h3>";
contentHtml += "<p>" + p.description + "</p>";
contentHtml += "<p><a target='_blank' href='" + p.source + "'>Source</a></p>";
var infoWindow = new google.maps.InfoWindow({
content: contentHtml
});
var marker = new google.maps.Marker({
position: { lat: p.location[0], lng: p.location[1] },
map: map,
title: p.title
});
marker.addListener('click', function() {
if (currentWindow) {
currentWindow.close();
}
currentWindow = infoWindow;
infoWindow.open(map, marker);
});
});
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAzPBhR4xnk03txCnzEA6wEiPBxdNfrCKk&callback=initMap" async defer></script>
</body>
</html>