-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
159 lines (128 loc) · 5.1 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
<!DOCTYPE html>
<html>
<head>
<title>Mansholt, Landschap in Perspectief</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/leaflet.css" />
<link rel="icon" type="image/png" href="img/favicon.png">
<!-- <link href='http://fonts.googleapis.com/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'> -->
<script src="js/d3.min.js"></script>
<script src="js/leaflet.js"></script>
</head>
<body>
<div class="header" id="main-header">
<h1>Mansholt, Landschap in Perspectief</h1>
<h3><a href="http://www.bureau-europa.nl/nl/manifestations/mansholt_landscape_in_perspective/">18 januari – 6 april 2014, Bureau Europa, Maastricht</a></h3>
</div>
<script charset="utf-8">
// ## TODO:
// - kleuren gewassenkaart afmaken.
var exhibition = false;
var hash = window.location.hash.substring(1);
if (hash === "exhibition") {
exhibition = true;
d3.select("#main-header").remove();
}
var maps,
mapLocked = false,
gutter = 5;
function px(x) {
return x + "px";
}
function row(orientation, i) {
var row = orientation === "landscape" ? Math.floor(i / 3) : Math.floor(i / 2);
return row;
}
function column(orientation, i) {
var column = orientation === "landscape" ? (i % 3) : (i % 2);
return column;
}
function rowHeight(orientation, height) {
return (height - gutter) / (orientation === "landscape" ? 2 : 3) - gutter;
}
function columnWidth(orientation, width) {
return (width - gutter) / (orientation === "landscape" ? 3 : 2) - gutter;
}
d3.json("maps.json", function(json) {
maps = json;
var container = d3.select("body").selectAll("div.map-container")
.data(maps.features).enter()
.append("div")
.each(setPosition)
.attr("class", "map-container")
.attr("id", function(d, i) { return "map-container" + i; });
var header = container
.append("a")
.attr("href", function (d, i) {
return "map/#" + d.properties.name + (exhibition ? "/exhibition" : "");
})
.append("div")
.attr("class", "map-header")
.append("div")
.attr("class", "map-header-wrapper");
header.append("h2")
.html(function(d) { return d.properties.title; });
var p = header.append("p")
p.append("span").attr("class", "link").html("kaart en details");
p.append("span").html("→");
container.append("div")
.attr("class", "map")
.attr("id", function(d, i) { return "map" + i; })
.each(function(d, i) {
var map = L.map('map' + i, {
minZoom: 8,
maxZoom: 15,
zoomControl: false
});
d3.select("#map" + i).style("background-color", "white");
map.on("mousemove", function() { setActiveMap(i); });
map.on("dragstart", function() { lockActiveMap(i); });
map.on("zoomstart", function() { lockActiveMap(i); });
map.on("dragend", function() { unlockActiveMap(i); });
map.on("zoomend", function() { unlockActiveMap(i); });
map.attributionControl.setPrefix('');
// L.tileLayer("http://tiles.waag.org/v2/mansholt/{z}/{x}/{y}.png", {
L.tileLayer("http://rtiles.waag.org/services/mansholt/tiles/{z}/{x}/{y}.png", {
attributionControl: false
}).addTo(map);
map.setView([d.geometry.coordinates[1], d.geometry.coordinates[0]], d.properties.zoom1);
});
update();
});
function lockActiveMap(i) {
mapLocked = true;
setActiveMap(i);
}
function unlockActiveMap(i) {
mapLocked = false;
setActiveMap(i);
}
function setActiveMap(i) {
if (!mapLocked) {
d3.selectAll(".map-container").classed("active", false);
d3.selectAll("#map-container" + i).classed("active", true);
}
}
function setPosition(d, i) {
var width = window.innerWidth,
height = window.innerHeight,
orientation = width > height ? "landscape" : "portrait";
d3.select(this)
.style("left", px(gutter + column(orientation, i) * (columnWidth(orientation, width) + gutter)))
.style("top", px(gutter + row(orientation, i) * (rowHeight(orientation, height) + gutter)))
.style("width", px(columnWidth(orientation, width)))
.style("height", px(rowHeight(orientation, height)));
//.classed("top", row(orientation, i) == 0)
//.classed("bottom", row(orientation, i) > 0);
}
function update(map) {
d3.select("body").selectAll(".map-container")
.data(maps.features)
.each(setPosition);
}
window.onresize = update;
</script>
</body>
</html>