-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
398 lines (357 loc) · 14 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<html>
<head>
<meta charset=utf-8 />
<title>GIS Day Esri-Leaflet</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="http://cdn-geoweb.s3.amazonaws.com/esri-leaflet/1.0.0-rc.4/esri-leaflet.js"></script>
<!-- Load Esri Clustered Feature Layer from CDN -->
<script src="http://cdn-geoweb.s3.amazonaws.com/esri-leaflet-clustered-feature-layer/1.0.0-rc.4/esri-leaflet-clustered-feature-layer.js"></script>
<!-- Include Leaflet.markercluster via rawgit.com, do not use in production -->
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/Leaflet/Leaflet.markercluster/v0.4.0/dist/MarkerCluster.Default.css">
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/Leaflet/Leaflet.markercluster/v0.4.0/dist/MarkerCluster.css">
<script src="https://cdn.rawgit.com/Leaflet/Leaflet.markercluster/v0.4.0/dist/leaflet.markercluster.js"></script>
<!-- Fonts -->
<script type="text/javascript" src="http://fast.fonts.net/jsapi/4a60d16b-c9e4-404d-89d3-809adb97d65c.js"></script>
<!-- Esri Leaflet Geocoder -->
<script src="http://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/1.0.0-rc.2/esri-leaflet-geocoder.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/1.0.0-rc.2/esri-leaflet-geocoder.css">
<script src="leaflet-hash.js"></script>
<!-- More controls -->
<script src='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.24.0/L.Control.Locate.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.24.0/L.Control.Locate.css' rel='stylesheet' />
<!--[if lt IE 9]>
<link href='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.21.0/L.Control.Locate.ie.css' rel='stylesheet' />
<![endif]-->
<style>
body {margin:0;padding:0;}
#map {position: absolute;top:0;bottom:0;right:0;left:0;}
/* Clusters */
.cluster {
color: #fff;
font-size: 14px;
font-weight: 700;
}
/* Small */
.cluster-small {
box-shadow: 0 0 4px rgba(255,255,255,0.15);
background-color: rgba(140,177,210,0.4);
margin-left: -20px;
margin-top: -20px;
width: 40px;
height: 40px;
border-radius: 20px;
}
.cluster-small:hover {
background-color: rgba(140,177,210,0.7);
}
.cluster-small:hover > div {
background-color: rgba(140,177,210,0);
}
.cluster-small > div {
background-color: rgba(140,177,210,0.85);
width: 24px;
height: 24px;
margin-left: 8px;
margin-top: 8px;
text-align: center;
border-radius: 24px;
}
.cluster-small > div > span {
line-height: 24px;
}
/* Medium */
.cluster-medium {
box-shadow: 0 0 6px rgba(255,255,255,0.15);
background-color: rgba(97,147,179,0.4);
margin-left: -30px;
margin-top: -30px;
width: 60px;
height: 60px;
border-radius: 30px;
}
.cluster-medium > div {
background-color: rgba(97,147,179,0.85);
width: 44px;
height: 44px;
margin-left: 8px;
margin-top: 8px;
text-align: center;
border-radius: 22px;
}
.cluster-medium > div > span {
line-height: 44px;
}
.cluster-medium:hover {
background-color: rgba(97,147,179,0.7);
}
.cluster-medium:hover > div {
background-color: rgba(97,147,179,0);
}
/* Large */
.cluster-large {
box-shadow: 0 0 10px rgba(255,255,255,0.15);
background-color: rgba(59,110,128,0.4);
margin-left: -40px;
margin-top: -40px;
width: 80px;
height: 80px;
border-radius: 40px;
}
.cluster-large > div {
background-color: rgba(59,110,128,0.85);
width: 60px;
height: 60px;
margin-left: 10px;
margin-top: 10px;
text-align: center;
border-radius: 30px;
}
.cluster-large:hover {
background-color: rgba(59,110,128,1);
}
.cluster-large:hover {
background-color: rgba(59,110,128,0.7);
}
.cluster-large:hover > div {
background-color: rgba(59,110,128,0);
}
.cluster-large > div > span {
line-height: 60px;
}
/* xLarge */
.cluster-xlarge {
box-shadow: 0 0 16px rgba(255,255,255,0.15);
background-color: rgba(20,72,77,0.4);
margin-left: -60px;
margin-top: -60px;
width: 120px;
height: 120px;
border-radius: 60px;
}
.cluster-xlarge:hover {
background-color: rgba(20,72,77,0.7);
}
.cluster-xlarge:hover > div {
background-color: rgba(20,72,77,0);
}
.cluster-xlarge > div {
background-color: rgba(20,72,77,0.85);
width: 100px;
height: 100px;
margin-left: 10px;
margin-top: 10px;
text-align: center;
border-radius: 50px;
}
.cluster-xlarge > div > span {
line-height: 100px;
}
/* Popup */
.leaflet-popup-pane h3 {
font-family:'Avenir LT W01 65 Medium';
}
.leaflet-popup-content-wrapper {
border-radius: 6px;
overflow: hidden;
}
.leaflet-popup-content {
width: 250px;
font-size: 14px;
}
.leaflet-popup-content p {
margin: 1em 0;
/*max-height: 150px;*/
/*overflow-y: scroll;*/
}
.leaflet-popup-content h2 {
margin-top: 15px;
}
.popup-bottom {
background: #f2f2f2;
margin: 1em -20px -1em;
padding: .5em 20px;
}
.popup-bottom p {
margin: .5em 0;
}
.popup-host {
font-size: 12px;
margin-left: -20px;
margin-right: -20px;
padding: 1px 20px;
background-color: #d9d9d9;
}
.leaflet-popup-tip {
background: #f2f2f2;
}
.marker {
margin-left: -15px;
margin-top: -15px;
width: 30px;
height: 30px;
border-radius: 15px;
}
.marker path, .marker circle {
fill: rgba(255, 255, 255, 0.9);
}
.marker > div {
background-color: rgba(59,110,128,0.7);
width: 14px;
height: 14px;
margin-left: 5px;
margin-top: 5px;
padding: 3px;
text-align: center;
border-radius: 14px;
}
.marker:hover {
background-color: rgba(140,177,210,0.7);
}
/* .marker:hover > div {
background-color: rgba(140,177,210,1);
}*/
/* Esri Geocode control */
.geocoder-control-header {
font-size: 11px;
letter-spacing: 0.0725em;
}
.geocoder-control-suggestions .geocoder-control-suggestion.geocoder-control-selected,
.geocoder-control-suggestions .geocoder-control-suggestion:hover {
background-color: rgba(180,200,220,1);
}
.geocoder-control-expanded,
.leaflet-touch .geocoder-control-expanded {
width: 295px;
}
</style>
</head>
<body>
<a href="https://github.com/esri/gis-day-map"><img style="position: absolute; top: 0; right: 0; border: 0; width: 100px; z-index:100;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>
<div id="map"></div>
<script>
var map,
clusterLayer,
singlePin;
map = L.map('map', { maxZoom: 16 }).setView([15, -35], 2);
// Use Esri Streets or GrayLables
//L.esri.basemapLayer('Gray').addTo(map);
baseLayer = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="http://cartodb.com/attributions">CartoDB</a>',
subdomains: 'abcd',
maxZoom: 19
}).addTo(map);
singlePin = L.divIcon({
html: '<div><svg version="1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50"/></svg></div>',
className: 'marker',
iconSize: null,
popupAnchor: [0, -11]
});
// Create cluster layer from GIS Day data in AGOL
clusterLayer = L.esri.clusteredFeatureLayer('http://services7.arcgis.com/gI63GN4f691BWQJB/arcgis/rest/services/Open_Data_Day_Events/FeatureServer/0',
{
spiderfyOnMaxZoom: true,
showCoverageOnHover: false,
maxClusterRadius: 55,
// Single pins
pointToLayer: function (geojson, latlng) {
return L.marker(latlng, {
icon: singlePin
});
},
// Format popups
onEachFeature: function (geojson, marker) {
var url = geojson.properties.URL ? "<a target='_blank' href='" + geojson.properties.URL.toString() + "'>" + geojson.properties.Name + "</a>" : geojson.properties.Name,
desc = geojson.properties.Description,
dateTime = new Date(geojson.properties.DateTime),
min = dateTime.getMinutes() ? dateTime.getMinutes() : "00",
hr = dateTime.getUTCHours(),
ampm = hr < 12 ? "AM" : "PM";
hr = hr > 12 ? hr - 12 : hr;
dateTime = dateTime.toDateString() + ", " + hr + ":" + min + " " + ampm;
marker.bindPopup("<h2>" + url + "</h2><p>" + desc + "<br>" + geojson.properties.Type + " " + geojson.properties.Audience + "</p></div><div class='popup-bottom'><p>DATE: " + dateTime + "</p><p>ADDRESS: " + geojson.properties.Address + "</p><div class='popup-host'><p>HOST: <a target='_top' href='mailto:" + geojson.properties.Email + "?subject=GIS Day Event'>" + geojson.properties.Organization + "</a></p></div></div>");
// store data
marker.properties = {};
marker.properties.Name = geojson.properties.Name;
},
// Cluster styles
iconCreateFunction: function (cluster) {
var count = cluster.getChildCount(),
clusterSize;
// Get cluster count
if (count > 1 && count <= 5)
clusterSize = "small";
else if (count > 5 && count <= 20)
clusterSize = "medium";
else if (count > 20 && count <= 50)
clusterSize = "large";
else
clusterSize = "xlarge";
// Create cluster
return new L.DivIcon({
html: "<div><span>"+count+"</span></div>",
className:"cluster cluster-"+clusterSize,
iconSize: null
});
}
}).addTo(map);
// Auto-show popup
clusterLayer.on('mouseover', function (e) {
e.layer.openPopup();
});
// Zoom in to single feature, always show popup
clusterLayer.on('click', function (e) {
e.layer.openPopup();
});
// Show popup
clusterLayer.on('mousedown', function (e) {
e.layer.openPopup();
});
// Zoom
clusterLayer.on('dblclick', function(e) {
map.setZoomAround(e.latlng, map.getZoom() + 1);
});
// Prevent toggling/flickering effect of popup
map.on('mouseup', function(e) {
if (e.target._popup) {
e.target._popup._isOpen = false;
}
});
// Add geolocation control
L.control.locate({
follow: false,
icon: 'icon-location',
showPopup: false,
locateOptions: {
maxZoom: 13
}
}).addTo(map);
// Add search control to search world places as well as GIS Day feature service
var searchControl = new L.esri.Geocoding.Controls.Geosearch({
placeholder: "Search for event name, host or location",
useMapBounds: false,
providers: [
new L.esri.Geocoding.Controls.Geosearch.Providers.FeatureLayer('http://services7.arcgis.com/gI63GN4f691BWQJB/arcgis/rest/services/Open_Data_Day_Events/FeatureServer/0', {
searchFields: ['Place', 'Program', 'Organizers'],
label: 'WWC Open Data Day Events',
bufferRadius: 5000,
formatSuggestion: function(feature){
return feature.properties.Place + ' - ' + feature.properties.Program + ' - ' + feature.properties.Organizers;
}
})
]
}).addTo(map);
// Show feature and popup when selected
searchControl.on("results", function(data){
if(data.results && data.results[0].properties.FID){
clusterLayer.once('load', function(){
clusterLayer.getFeature(data.results[0].properties.FID).openPopup();
});
}
});
</script>
</body>
</html>