-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
106 lines (87 loc) · 2.93 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://i.imgur.com/8d7aQc0.png" />
<meta name="twitter:title" content="All US Counties" />
<title>Every County</title>
<link href="https://fonts.googleapis.com/css?family=Alegreya+Sans+SC" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Alegreya Sans SC', sans-serif;
text-align: center;
width: 90%;
margin: 10px auto 10px auto;
}
.hidden {
visibility: hidden;
opacity: 0;
transition: visibility 0s 0.5s, opacity 0.5s linear;
}
#map {
padding: 0;
padding-top: 20px;
margin: 0;
}
#county {
/*text-align: center; */
display: inline-block;
width: 80px;
height: 80px;
}
</style>
</head>
<body>
<h1> Every US County - Including Puerto Rico and Minor Outlying Islands</h1>
<br>
<div id="loader">Loading..</div>
<div id="map"></div>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://unpkg.com/topojson@3"></script>
<script>
d3.json("latest-simple.json").then(function (county) {
document.getElementById("loader").classList.add('hidden');
var projection = d3.geoAlbers();
var path = d3.geoPath().projection(projection);
for (var x in county.features) {
var newJson = {
"type": "FeatureCollection",
//"name": county.features[x].properties.NAME,
"features": [
county.features[x]
]
};
var width = 75,
height = 75;
projection.fitSize([width, height], newJson)
var map = d3.select("#map")
.append("div")
.attr("id", "county")
//.attr("class", newJson.name);
var svg = map
.append("svg")
.attr("width", width)
.attr("height", height)
var data = svg.append("g")
.selectAll("path")
.data(newJson.features)
.enter()
.append("path")
.attr("d", path)
// .style("fill-opacity", "0.0")
//.attr("class", "county " + newJson.name)
.style("fill", "whitesmoke")
.style("stroke-width", "0.5")
.style("stroke", "#000")
.style("fill-opacity", "0.5")
}
})
</script>
</body>
</html>