-
Notifications
You must be signed in to change notification settings - Fork 1
/
pyladies-cluster-map.html
129 lines (97 loc) · 6.01 KB
/
pyladies-cluster-map.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
<html>
<head>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-158857375-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-158857375-1');
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> PyLadies Cluster Map </title>
<link href="https://py-community.github.io/resources/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://py-community.github.io/resources/leaflet-1.5.1/leaflet.css"/>
<link rel="stylesheet" href="https://py-community.github.io/resources/leaflet-awesome-markers/dist/leaflet.awesome-markers.css">
<link rel="stylesheet" href="https://py-community.github.io/resources/leaflet.markercluster/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://py-community.github.io/resources/leaflet.markercluster/dist/MarkerCluster.Default.css" />
<link href="https://py-community.github.io/resources/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://py-community.github.io/resources/css/custom.min.css" rel="stylesheet">
<script src="https://py-community.github.io/resources/js/jquery.min.js"></script>
<script src="https://py-community.github.io/resources/leaflet-1.5.1/leaflet.js"></script>
<script src="https://py-community.github.io/resources/leaflet-awesome-markers/dist/leaflet.awesome-markers.js"></script>
<script src="https://py-community.github.io/resources/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
<style>
#map{ height: 91%; width:100%; }
</style>
</head>
<body style="background:#ffffff;">
<div class="buttons">
<button type="button" class="btn btn-info btn-lg btn-block bg-red" onclick="window.location.href='pyladies.html'"> BACK TO PYLADIES DASHBOARD </button>
</div>
<div id="map"></div>
<script type="text/javascript">// initialize the map
// maxZoom reduces the zoom level when you click on the cluster. Markers are closer at a smaller zoom level
var map = L.map('map', { maxZoom: 5}).setView([10, 10],2);
// load a tile layer
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',
{
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
maxZoom: 18,
minZoom: 1
}).addTo(map);
setTimeout(function () { map.invalidateSize() }, 1200);
// load GeoJSON from an external file
$.getJSON("https://raw.githubusercontent.com/py-community/pyladies/master/docs/data/pyladies_map_data.geojson",function(data){
//console.log(data.features[0])
L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';
var blueMarker = L.AwesomeMarkers.icon({
icon: 'check-circle',
markerColor: 'red'
});
var darkblueMarker = L.AwesomeMarkers.icon({
icon: 'user-times',
markerColor: 'darkblue'
});
var orangeMarker = L.AwesomeMarkers.icon({
icon: 'user-times',
markerColor: 'orange'
});
var markers = L.markerClusterGroup({
maxClusterRadius: function (zoom) {
return (zoom <= 10) ? 70 : 1; // radius in pixels
}
});
for (var i = 0; i < data.features.length; i++) {
var a = data.features[i].geometry.coordinates;
past_events = data.features[i].properties.past_events;
if ( past_events >= 0 & data.features[i].properties.days_since_last_event <= 180 | data.features[i].properties.upcoming_events > 0) {
var marker = L.marker(new L.LatLng(a[1], a[0]), {icon: blueMarker});
marker.bindPopup("<b>" + data.features[i].properties.url + '</b>' + '<br/>' + 'Created: '+ data.features[i].properties.created + '<br/>' +
'Members: ' + data.features[i].properties.members + '<br/>' + 'Past Events: '+ data.features[i].properties.past_events
+ '<br/>' + 'Upcoming Events: '+ data.features[i].properties.upcoming_events + '<br/>' + 'Last Event Date: '+ data.features[i].properties.last_event+ '<br/>' + 'Active');
markers.addLayer(marker);
}
if (data.features[i].properties.days_since_last_event > 180 & past_events != 0 & data.features[i].properties.upcoming_events == 0 ){
var marker = L.marker(new L.LatLng(a[1], a[0]), {icon: darkblueMarker});
marker.bindPopup("<b>" + data.features[i].properties.url + '</b>' + '<br/>' + 'Created: '+ data.features[i].properties.created + '<br/>' +
'Members: ' + data.features[i].properties.members + '<br/>' + 'Past Events: '+ data.features[i].properties.past_events
+ '<br/>' + 'Upcoming Events: '+ data.features[i].properties.upcoming_events + '<br/>' + 'Last Event Date: '+ data.features[i].properties.last_event + '<br/>' + 'Months Inactive: '+ Math.round(data.features[i].properties.days_since_last_event/30) + ' months' + '<br/>' + 'Inactive: <a href="https://github.com/pyladies/info/"><b>Become an Organizer!</b></a>');
markers.addLayer(marker);
}
if ( past_events == 0 & data.features[i].properties.upcoming_events == 0) {
var marker = L.marker(new L.LatLng(a[1], a[0]), {icon: orangeMarker});
marker.bindPopup("<b>" + data.features[i].properties.url + '</b>' + '<br/>' + 'Created: '+ data.features[i].properties.created + '<br/>' +
'Members: ' + data.features[i].properties.members + '<br/>' + 'Past Events: '+ data.features[i].properties.past_events
+ '<br/>' + 'Upcoming Events: '+ data.features[i].properties.upcoming_events + '<br/>' + 'Last Event Date: '+ data.features[i].properties.last_event + '<br/>' + 'Months Inactive: '+ Math.round((new Date() - new Date(data.features[i].properties.created) ) /(30*60*60*24*1000)) + ' months' + '<br/>' + 'Inactive: <a href="https://github.com/pyladies/info/"><b>Become an Organizer!</b></a>');
markers.addLayer(marker);
}
}
map.addLayer(markers);
});
</script>
</body>
</html>