-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
73 lines (59 loc) · 1.74 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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Kaart van NL</title>
<script src="js/d3.js"></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="container"><h1>De steden van Nederland</h1></div>
<script>
var canvas = d3.select("#container").append("svg")
.attr("width", 980)
.attr("height", 780)
d3.json("json/shertogenbosch.geojson", function (data) {
var group = canvas.selectAll("g")
.data(data.features)
.enter()
.append("g");
console.log(data.features);
var projection = d3.geo.mercator().scale(8000).translate([-300,8900]);
var path = d3.geo.path().projection(projection);
var areas = group.append("path")
.attr("d", path)
.attr("class", "area")
.attr("stroke", "white")
.attr("stroke-width", 1)
.attr("fill", "#F96");
canvas.selectAll('t')
.data(data.features)
.enter().append('text')
.attr("x", function (d) { return (path.centroid(d)[0])})
.attr("y", function (d) { return (path.centroid(d)[1])-10})
.attr("text-anchor", "middle")
.transition()
.delay(function(d, i) {
return i * 4000;
})
.duration(4000)
.text(function (d) { return d.properties.NAME_2; }).remove();
canvas.selectAll("circle")
.data(data.features)
.enter().append("circle")
.transition()
.delay(function(d, i) {
return i * 4000;
})
.attr("cx", function(d) {
return (path.centroid(d)[0]);
})
.attr("cy", function(d) {
return (path.centroid(d)[1]);
}).attr("r", 5)
.style("fill", "red")
.duration(4000).remove();
});
</script>
</body>
</html>