-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
102 lines (99 loc) · 4.17 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
<!doctype html>
<html lang="es-ES">
<head>
<style>
/*.js-map {
width: 400px;
}*/
</style>
</head>
<body>
<div class="js-map"></div>
<script src="../node_modules/d3/d3.min.js"></script>
<script src="../node_modules/topojson/build/topojson.min.js"></script>
<script src="../node_modules/rbush/rbush.js"></script>
<script src="../spam.js"></script>
<script type='text/javascript'>
/*
{
features: (make it optional!),
static: {
prepaint:,
paintfeature:,
postpaint:
},
dynamic: {
prepaint:,
postpaint:
},
click:
}
*/
// TODO queue.js
d3.json("municipalities.json", function(error, d) {
d3.json("roads.json", function(error, roads) {
topojson.presimplify(d)
topojson.presimplify(roads)
console.log(d)
console.log(d3.select(".js-map").node().getBoundingClientRect().width)
var hover = null
var map = new ZoomableCanvasMap({
element: ".js-map",
projection: null, // TODO how to automagically detect this?
data: [{
features: topojson.feature(d, d.objects["municipalities"]),
static: {
prepaint: function(parameters) {
console.log("PRE")
},
paintfeature: function(parameters, d) {
//console.log(d)
/*if (d.properties.name[0] < "H")
parameters.context.fillStyle = "blue"
else*/
parameters.context.fillStyle = "red"
parameters.context.fill()
}
},
dynamic: {
postpaint: function(parameters) {
if (!hover)
return
parameters.context.beginPath()
parameters.context.lineWidth = 1 / parameters.scale / parameters.projectedScale
parameters.path(hover)
parameters.context.stroke()
}
},
events: {
click: function(parameters, d) { // TODO replace map with parameters?
console.log("CLICK")
console.log(parameters)
parameters.map.zoom(d)
},
hover: function(parameters, d) {
//if (d)
// console.log("HOVER " + d.properties.name)
hover = d
parameters.map.paint()
}
}
}/*,
{
features: topojson.feature(roads, roads.objects["roads"]),
static: {
paintfeature: function(parameters, d) {
parameters.context.lineWidth = 1 / parameters.scale
parameters.context.strokeStyle = "black"
parameters.context.stroke()
}
}
}*/]
})
map.init()
//console.log(map)
})
})
</script>
</body>
</html>