-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmap.html
25 lines (23 loc) · 858 Bytes
/
map.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<svg width="800px" height="600px"></svg>
<script type="text/javascript" src='./libs/d3.js'></script>
<script type="text/javascript" src="http://d3js.org/topojson.v1.min.js"></script>
<script type="text/javascript">
d3.json("./police/map/county.json", function(topodata) {
var features = topojson.feature(topodata, topodata.objects["County_MOI_1041215"]).features;
// 這裡要注意的是 topodata.objects["county"] 中的 "county" 為原本 shp 的檔名
var path = d3.geo.path().projection( // 路徑產生器
d3.geo.mercator().center([121,24]).scale(6000) // 座標變換函式
);
d3.select("svg").selectAll("path").data(features)
.enter().append("path").attr("d",path);
});
</script>
</body>
</html>