-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathindex.html
69 lines (63 loc) · 1.96 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
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.mpio {fill : #ddc;}
.mpio._44279 { fill: #fff; }
.mpio-borde {
fill: none;
stroke: #fff;
stroke-linejoin: round;
stroke-width: 0.5;}
.depto-borde {
fill: none;
stroke: #fff;
stroke-linejoin: round;
stroke-width: 1;}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 900,
height = 900;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
/*
ogr2ogr -f GeoJSON depts.json depto.shp -s_srs EPSG:26986 -t_srs EPSG:4326
topojson --id-property NOMBRE_DPT -p name=NOMBRE_DPT -p name -o colombia-departamentos.json depts.json
*/
d3.json("colombia-municipios.json", function(error, co) {
var subunits = topojson.feature(co, co.objects.mpios);
var projection = d3.geo.mercator()
.scale(2000)
.translate([width / 2, height / 2])
.center([-61,43])
.rotate([2,3,2]);
var path = d3.geo.path()
.projection(projection);
svg.append("path")
.datum(subunits)
.attr("d", path);
svg.selectAll(".mpio")
.data(topojson.feature(co, co.objects.mpios).features)
.enter().append("path")
.attr("class", function(d) { return "mpio " + "_" + d.id; })
.attr("d", path);
svg.append("path")
.datum(topojson.mesh(co, co.objects.mpios, function(a, b) { return a !== b; }))
.attr("d", path)
.attr("class", "mpio-borde");
svg.append("path")
.datum(topojson.mesh(co, co.objects.depts, function(a, b) { return a !== b; }))
.attr("d", path)
.attr("class", "depto-borde");
/* svg.selectAll(".dept-label")
.data(topojson.feature(co, co.objects.depts).features)
.enter().append("text")
.attr("class", function(d) { return "dept-label " + d.id; })
.attr("transform", function(d) { return "translate(" + path.centroid(d) + ")"; })
.attr("dy", ".35em")
.text(function(d) { return d.properties.name; });*/
});
</script>