-
Notifications
You must be signed in to change notification settings - Fork 63
/
index.html
72 lines (60 loc) · 2.31 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>The Python Community Map</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="shortcut icon" type="image/png" href="logo.png">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="map"></div>
<footer>
<img class="logo" src="logo.png" />
<span class="footer-text">Python Communities Around the World, <a target="_blank" href="https://github.com/jonatasbaldin/python-community-map#how-to-add-a-new-community-to-the-map">add yours!</a></span>
<span class="space"></span>
<span class="made-by">by <a target="_blank "href="https://deployeveryday.com/">Jojo</a></span>
</footer>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB5n6IqLiunv2aS2Y8FcE0dUD-Mn6iTVXY"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/yamljs/0.3.0/yaml.min.js"> </script>
<script>
var URL = 'https://raw.githubusercontent.com/jonatasbaldin/python-community-map/master/communities.yaml'
fetch(URL).then(function(response) {
response.text().then(function(data) { initMap(data) })
})
function infoWindowContent(url, name) {
var content = `
<div id="content">
<div id="siteNotice"></div>
<div id="bodyContent">
<p><a target="_blank" href="${url}">${name}</a></p>
</div>
</div>
`
return content
}
function initMap(communities) {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: {lat: -0, lng: -18}
});
var infowindow = new google.maps.InfoWindow({
content: '',
});
markers = YAML.parse(communities)
markers.forEach(function(item) {
item['marker'] = new google.maps.Marker({
position: {lat: item.lat, lng: item.lng},
map: map,
title: item.name,
})
item['marker'].addListener('click', function(){
infowindow.setContent(infoWindowContent(item.name, item.url))
infowindow.open(map, item['marker'])
})
})
}
</script>
</body>
</html>