forked from MarshalW/d3.hello
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.basic_map.html
More file actions
47 lines (40 loc) · 893 Bytes
/
5.basic_map.html
File metadata and controls
47 lines (40 loc) · 893 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Basic Map</title>
<script src="js/d3.v5.min.js"></script>
<style>
body {
margin: 0;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
svg {
width: 1000px;
height: 800px;
}
</style>
</head>
<body>
<!-- http://bl.ocks.org/almccon/fe445f1d6b177fd0946800a48aa59c71 -->
<script>
let width = 500
let height = 480
let svg = d3.select("body").append("svg")
let projection = d3.geoMercator()
.scale(width / 2 / Math.PI)
.translate([width / 2, height / 2])
let path = d3.geoPath()
.projection(projection)
let url = "data/world-110m.geojson"
d3.json(url).then((geojson) => {
svg.append("path")
.attr("d", path(geojson))
})
</script>
</body>
</html>