-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (59 loc) · 1.35 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
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: #fff;
stroke: #870f57;
stroke-width: 2px;
}
circle {
fill: #fff;
fill-opacity: 0.4;
stroke: #111;
}
path.active {
fill: pink;
}
</style>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/textures.js"></script>
<script>
var width = 960,
height = 500;
var svg = d3.select("body")
.append("svg");
var t = textures.lines()
.orientation("vertical")
.strokeWidth(1)
.shapeRendering("crispEdges");
svg.call(t);
svg.append("circle")
.style("fill", t.url());
svg.attr("width", width)
.attr("height", height)
var url = "./gminy.geo.json"
d3.json(url, function(error, gminy) {
window.gminy = gminy
console.log(gminy)
let geoData = topojson.topology(gminy)
var projection = d3.geoMercator().fitSize([width, height], gminy)
var path = d3.geoPath().projection(projection)
svg.selectAll("path")
.data(gminy.features)
.enter().append("path")
.attr("d", path)
.attr("fill", t.url())
.on("mouseover",function(d) {
d3.select(this)
.classed("active",true)
})
.on("mouseout",function(d){
d3.select(this)
.classed("active",false)
})
});
</script>
<div id="example"></div>
</body>