/
index.html
305 lines (253 loc) · 12 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-148957542-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-148957542-1');
</script>
<meta charset="utf-8">
<link rel="icon" href="Tree-v3.png">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Living Campus</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-search@2.9.8/src/leaflet-search.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"
integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
crossorigin=""></script>
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/leaflet-search@2.9.8/dist/leaflet-search.src.min.js"></script>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>
<style type="text/css">
#livingcampus {
height: 100vh;
}
.tooltip-img {
max-width: 200px;
max-height: 200px;
display: block;
margin-left: auto;
margin-right: auto;
}
.leaflet-pane.leaflet-popup-pane > div {
z-index: 200000;
}
.leaflet-bottom {
bottom: 10px;
}
.ui-dialog {
z-index: 1000 !important;
width: 75% !important;
}
.ui-dialog-titlebar {
background-color: #03335f;
color: #fff;
}
.ui-dialog-buttonset .ui-button {
background-color: #03335f !important;
color: #fff !important;
}
#credits-btn {
position: absolute;
bottom: 5%;
right: 5px;
z-index: 1000;
background-color: #03335f;
color: #fff;
font-size: 1.5em;
border-radius: 5px;
margin: 5px 10px 5px 5px;
padding: 5px;
}
</style>
</head>
<body>
<div id="livingcampus"></div>
<div id="dialog" title="About this Map">
<p>The Living Campus map was envisaged by Cara Palladino and Kate Fernandez (both of Alumnae Relations & Development) and supported by a Digital Bryn Mawr seed grant. The map was created through collaborations with Alicia Peaker (LITS), Dawn DiGiovanni (Facilities), Christian Zavica (Communications), Robin Parks (Communications), and through the labor and creativity of a number of students. In 2018, Lille van der Zanden (‘20) and Cara Navarro (‘20) collected data and photographs of the trees and objects represented on the map. Cara also designed early data structures for the map and created a working prototype. In 2019, Nisha Choudhary (‘21) built on this work, adding functionality and polishing the map while Andrew Tharler (Ph.D. Archaeology, '19) served as the Project Manager and helped bring the project to completion.</p>
<p>This map is not meant to be an exhaustive inventory of all of the dedicated trees and benches on campus. It is a dynamic project that changes as we identify missing elements or as new elements are added to campus.</p>
</div>
<button id="credits-btn">About</button>
<script type="text/javascript">
var donations = $.ajax({
url: "lc-data.geojson",
dataType: "json",
success: console.log("Data successfully loaded!"),
error: function(xhr) {
alert(xhr.statusText)
}
});
$.when(donations).done(function() {
var mymap = L.map('livingcampus').setView([40.027, -75.315], 18);
L.tileLayer('https://api.mapbox.com/styles/v1/apeaker/cjwjkimg30g211csavuccb0n6/tiles/256/{z}/{x}/{y}@2x?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 25,
id: 'mapbox.outdoors',
accessToken: 'pk.eyJ1IjoiYXBlYWtlciIsImEiOiJjamkwZW92YTAxN2FrM3Fyc2s5NGJ0ZDJmIn0.Ci_NG6faFCMzEC0BEgaYAQ'
}).addTo(mymap);
var objIcon = L.icon({
iconUrl: 'Lantern-v2.png',
iconSize: [30, 30], // size of the icon
iconAnchor: [15, 0], // point of the icon which will correspond to marker's location
popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor
});
var treeIcon = L.icon({
iconUrl: 'Tree-v3.png',
iconSize: [30, 30],
iconAnchor: [15, 15],
popupAnchor: [0, 0]
});
var donatedObjectsLayer = L.geoJSON(donations.responseJSON, {
filter: function(feature, layer)
{
if (feature.properties.icon == "object") {
return feature.properties.icon;
}
},
onEachFeature: function(feature, layer) {
var p = layer.feature.properties;
p.index = p.item + " | " + p.donor_id + " | " + p.dedi_id + " | " + p.inscription;
//only try to display image and data they exist
if (p.img_src != ''){
var img = '<img class ="tooltip-img" height="200px" src = "images/' + p.img_src + '" >';
// console.log(img.status);
} else img = '<img style="display:none">';
if(p.dedi_id != '') {
dedi = '<h2>Dedicated to '+ p.dedi_id +'</h2>';
} else {dedi = '';};
if(p.donor_id != '') {
donor = '<h2>Given by '+p.donor_id+'</h2>';
} else {donor = '';};
if(p.inscription != '') {
inscription = '<h3 style="text-align: center;"><i>'+p.inscription+'</i></h3>';
} else {inscription = '';};
var popup = (img + '<h1>' + p.item + '</h1>' + dedi + donor + inscription + feature.geometry.coordinates);
layer.bindPopup(popup),
layer.setIcon(objIcon)
}
}).addTo(mymap);
var donatedTreesLayer = L.geoJSON(donations.responseJSON, {
filter: function(feature, layer) {
if (feature.properties.icon == "tree") {
return feature.properties.icon;
}
},
onEachFeature: function(feature, layer) {
var q = layer.feature.properties;
q.index = q.item + " | " + q.donor_id + " | " + q.dedi_id + " | " + q.inscription;
//only try to display image if there's an image source
if (q.img_src != '') {
// img = document.createElement("img");
// img.src = "images/" + q.img_src;
// $(img).addClass('tooltip-img');
var img = '<img class ="tooltip-img" height="200px" src = "images/' + q.img_src + '" >';
// img.onload = function(){
// popup.update();
// }
} else img = '<img style="display:none">';
//italicize species names
var species = q.item.match(/\(([^)]+)\)/)[1];
var common = q.item.match(/^[^\(,]*/);
var item = '<h1>' + common + '<i>(' + species + ')</i></h1>';
if(q.dedi_id != '') {
dedi = '<h2>Dedicated to '+ q.dedi_id +'</h2>';
} else {dedi = '';};
if(q.donor_id != '') {
donor = '<h2>Given by '+q.donor_id+'</h2>';
} else {donor = '';};
if(q.inscription != '') {
inscription = '<h3><i>'+q.inscription+'</i></h3>';
} else {inscription = '';};
var popup = (img + item + dedi + donor + inscription + feature.geometry.coordinates);
//popup is binding before image is loaded, and so the height is not being calculated for the position of the tooltip
layer.bindPopup(popup),
layer.setIcon(treeIcon)
// mymap.on("popupopen", function(e){
// $(".leaflet-popup-content img:last").on("load", function(){
// e.popup.update();
// });
// });
}
}).addTo(mymap);
var champsLayer = L.geoJSON(donations.responseJSON, {
filter: function(feature, layer) {
if (feature.properties.state_champ == "yes") {
return feature.properties.state_champ;
}
},
onEachFeature: function(feature, layer) {
var r = layer.feature.properties;
if (r.img_src != '') {
var img = '<img class ="tooltip-img" height="200px" src = "images/' + r.img_src + '" >';
} else img = '<img style="display:none">';
//italicize species names
var species = r.item.match(/\(([^)]+)\)/)[1];
var common = r.item.match(/^[^\(,]*/);
var item = '<h1>' + common + '<i>(' + species + ')</i></h1>';
if(r.dedi_id != '') {
dedi = '<h2>Dedicated to '+ r.dedi_id +'</h2>';
} else {dedi = '';};
if(r.donor_id != '') {
donor = '<h2>Given by '+r.donor_id+'</h2>';
} else {donor = '';};
if(r.inscription != '') {
inscription = '<h3><i>'+r.inscription+'</i></h3>';
} else {inscription = '';};
var popup = (img + item + dedi + donor + inscription + feature.geometry.coordinates);
layer.bindPopup(popup),
layer.setIcon(treeIcon)
}
});
var overlayMaps = {
"Objects": donatedObjectsLayer
};
var baseLayers = {
"All Trees": donatedTreesLayer,
"State Champion Trees": champsLayer
}
L.control.layers(baseLayers, overlayMaps).addTo(mymap);
var mapLayers = L.layerGroup()
.addLayer(donatedTreesLayer)
.addLayer(donatedObjectsLayer)
.addTo(mymap);
var controlSearch = new L.Control.Search({
position: 'topleft', // where do you want the search bar?
layer: mapLayers, // name of the layer
propertyName: 'index',
initial: false,
zoom: 20, // set zoom to found location when searched
marker: false,
textPlaceholder: 'search...' // placeholder while nothing is searched
});
mymap.addControl(controlSearch)
});
$( function() {
$( "#dialog" ).dialog({
autoOpen: false,
height: "auto",
modal: true,
buttons: {
"Close": function(){
$(this).dialog("close");
}
}
});
$( "#credits-btn" ).on( "click", function() {
$( "#dialog" ).dialog( "open" );
});
} );
// $("#credits-btn").on("click", function(){
// $("#dialog").dialog("open");
// })
</script>
</body>
</html>