-
Notifications
You must be signed in to change notification settings - Fork 0
/
abolitionist.html
155 lines (139 loc) · 4.28 KB
/
abolitionist.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<html>
<head>
<meta charset="utf-8" />
<title>UGRR Map</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css" rel="stylesheet" />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; z-index: 1;}
#filters { position: absolute; top: 10px; left: 10px; z-index: 2; background-color: white; padding: 10px; border-radius: 4px;}
#filters p { margin: 0; padding: 0; cursor: pointer; font-family: sans-serif; margin: 4px; padding: 4px; border-radius: 4px; background-color: #eee; }
#filters p:hover { background-color: #333; color: #eee; }
#filters h2 {
font-size: 18px;
margin: 4px;
font-family: sans-serif;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="filters">
<h2 style="text-align:center;">Filtered Views</h2>
<a href="ugrr.html"><p>UGRR</p></a>
<a href="abolitionist.html"><p>Abolitionist</p></a>
<a href="poc.html"><p>Persons of Color</p></a>
<a href="index.html"><p>All</p></a>
</div><!-- /#filters -->
<script>
var dataURL = 'https://orbitist.space/ugrr/data?field_operative_type_tid=11'
mapboxgl.accessToken = 'pk.eyJ1Ijoib3JiaXRpc3QiLCJhIjoiYnpUTnJBdyJ9.uxgaJ0R9ZNsCcEnPNfo2ag';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/orbitist/ckhp89wu9016d19p81161l07y', // style URL
center: [-79.2746, 42.2590], // starting position [lng, lat]
zoom: 8 // starting zoom
});
map.on('load', function() {
map.addControl(new mapboxgl.NavigationControl())
map.addSource('ugrrDataSource', {
type: 'geojson',
data: dataURL,
cluster: true,
clusterMaxZoom: 14,
clusterRadius: 50
});
map.addLayer({
id: 'clusters',
type: 'circle',
source: 'ugrrDataSource',
filter: ['has', 'point_count'],
paint: {
'circle-color': [
'step',
['get', 'point_count'],
'#51bbd6',
100,
'#f1f075',
750,
'#f28cb1'
],
'circle-radius': [
'step',
['get', 'point_count'],
20,
100,
30,
750,
40
]
}
});
map.addLayer({
id: 'cluster-count',
type: 'symbol',
source: 'ugrrDataSource',
filter: ['has', 'point_count'],
layout: {
'text-field': '{point_count_abbreviated}',
'text-font': ['DIN Offc Pro Medium', 'Arial Unicode MS Bold'],
'text-size': 12
}
});
map.addLayer({
id: 'unclustered-point',
type: 'circle',
source: 'ugrrDataSource',
filter: ['!', ['has', 'point_count']],
paint: {
'circle-color': '#11b4da',
'circle-radius': 8,
'circle-stroke-width': 1,
'circle-stroke-color': '#fff'
}
});
map.on('click', 'clusters', function (e) {
var features = map.queryRenderedFeatures(e.point, {
layers: ['clusters']
});
var clusterId = features[0].properties.cluster_id;
map.getSource('ugrrDataSource').getClusterExpansionZoom(
clusterId,
function (err, zoom) {
if (err) return;
map.easeTo({
center: features[0].geometry.coordinates,
zoom: zoom
});
}
);
});
map.on('click', 'unclustered-point', function (e) {
let popupContent = '<a target="_blank" href="https://orbitist.space/ugrr/node/' + e.features[0].properties.nid + '">' + e.features[0].properties.firstName + ' ' + e.features[0].properties.lastName + '</a>'
var coordinates = e.features[0].geometry.coordinates.slice();
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
}
new mapboxgl.Popup()
.setLngLat(coordinates)
.setHTML(popupContent)
.addTo(map);
});
map.on('mouseenter', 'clusters', function () {
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', 'clusters', function () {
map.getCanvas().style.cursor = '';
});
map.on('mouseenter', 'unclustered-point', function () {
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', 'unclustered-point', function () {
map.getCanvas().style.cursor = '';
});
})
</script>
</body>
</html>