This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
/
test.html
52 lines (47 loc) · 1.61 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" rel="stylesheet" href="/static/css/materialize.min.css" media="screen,projection"/>
<style type="text/css">
svg {
border: 1px solid gray;
}
</style>
</head>
<body onload="sizeChange()">
<article class="container">
<section id="maps"></section>
</article>
<script src="/static/js/jquery-3.1.1.min.js"></script>
<script src="/static/js/underscore-min.js"></script>
<script src="/static/js/d3.v3.min.js"></script>
<script src="/static/js/topojson.v1.min.js"></script>
<script src="/static/js/queue.v1.min.js"></script>
<script type="text/javascript">
d3.select(window).on("resize", sizeChange);
d3.json('/static/json/iowa-counties.geojson', function(error, state) {
var svg = d3.select("#maps")
.append("section")
.attr("class", "row section")
.append("svg")
.attr("class", "map ")
.attr("width", "100%");
var projection = d3.geo.mercator()
.scale(7000)
.center([-93.15, 42.15]);
var path = d3.geo.path()
.projection(projection);
svg.append("g").selectAll(".state")
.data(state.features)
.enter().append("path")
.attr("d", path);
});
function sizeChange() {
d3.select("g").attr("transform", "scale(" + $("#maps").width()/900 + ")");
$("svg").height($("#maps").width()*0.618);
}
</script>
</body>
</html>