-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (66 loc) · 2.09 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
<!DOCTYPE html>
<html>
<head>
<title>Great Vancouver Regional District Maps</title>
<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>
<script src="jquery-2.1.1.min.js"></script>
<style>
#map {
width: 1200px;
height: 800px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// Adapted from https://bl.ocks.org/mejackreed/15f4c1c40c36123547f2f401f06248a3
var map = L.map('map');
L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
}).addTo(map);
var imageUrl = 'http://iiif.library.ubc.ca/image/cdm.gvrdmaps.1-0135075.0000/full/full/0/default.jpg',
imageBounds = [[49.434, -123.333], [48.974, -121.638]];
var imageOverlay = L.imageOverlay(imageUrl, imageBounds, {opacity: 0.6}).addTo(map);
var template = '<div style="min-height: 340px;"><h2>{title}</h2><div><a href="{subject}" target=_blank><img src="{purl}" style="max-width: 300px;"/></a></div>'
function onEach(feature, layer) {
layer.on('click', function() {
$.getJSON("gvrd_full.geojson", function(info) {
var popup = L.popup({
keepInView: true
})
.setContent(L.Util.template(template, {
title: feature.properties.title,
purl: feature.properties.purl,
subject: feature.properties.subject
})
);
layer.bindPopup(popup).openPopup();
})
})
}
var links = $.getJSON("gvrd_full.geojson", function(data) {
console.log(data);
var indexMap = L.geoJson(data, {
onEachFeature: onEach,
style: function(feature) {
return {
weight: 1
}
}
}
).addTo(map);
var baseMaps = {
"Base Map": map
};
var overlayMaps = {
"Index Map": imageOverlay
};
L.control.layers(baseMaps, overlayMaps).addTo(map);
map.fitBounds(indexMap.getBounds());
});
</script>
</body>
</html>