Skip to content

Instantly share code, notes, and snippets.

@rveciana
Last active April 14, 2016 10:23
Show Gist options
  • Save rveciana/eaf7bce2b2cc8f90d2ac9142659962ed to your computer and use it in GitHub Desktop.
Save rveciana/eaf7bce2b2cc8f90d2ac9142659962ed to your computer and use it in GitHub Desktop.
transverseMercatorChile
license: gpl-3.0
height: 700
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.land {
fill: #222;
}
.county-boundary {
fill: none;
stroke: #fff;
stroke-width: .5px;
}
.state-boundary {
fill: none;
stroke: #fff;
}
.border {
stroke: #000;
fill: none;
}
.graticule {
fill: none;
stroke: #777;
stroke-width: .5px;
stroke-opacity: .5;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="https://rawgit.com/rveciana/d3-composite-projections/v0.4.0/transverseMercatorChile-proj.min.js"></script>
<script>
var width = 300,
height = 700;
var projection = d3.geo.transverseMercatorChile()
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("https://rawgit.com/rveciana/5919944/raw/c7f93e1500e11b536ad39ef80c1137d84b191229/chile.json", function(error, chile) {
var land = topojson.feature(chile, chile.objects.chile);
svg.selectAll(".region")
.data(land.features)
.enter()
.append("path")
.attr("d", path)
.style("stroke","#000")
.style("stroke-width",".5px")
.style("fill","#aca")
.attr("class","region")
.on("mouseover", function(d,i) {
d3.select(this)
.transition()
.style("fill", "red");
})
.on("mouseout", function(d,i) {
d3.select(this)
.transition()
.style("fill", "#aca");
});
svg
.append("path")
.style("fill","none")
.style("stroke","#000")
.attr("d", projection.getCompositionBorders());
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment