Skip to content

Instantly share code, notes, and snippets.

@josecarlosgonz
Last active August 29, 2015 14:01
Show Gist options
  • Save josecarlosgonz/0ce2a73795c9d12eff9d to your computer and use it in GitHub Desktop.
Save josecarlosgonz/0ce2a73795c9d12eff9d to your computer and use it in GitHub Desktop.
Map of Mexican States
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.states {
fill: #222;
}
.states :hover {
fill: orange;
}
</style>
<body>
<script type="text/javascript" src = "javascripts/d3.js"></script>
<script type="text/javascript" src = "javascripts/topojson.js"></script>
<script>
var width = 960,
height = 628;
var path = d3.geo.path()
.projection(null);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("states.json", function(error, mx) {
console.log("Map area")
svg.append("g")
.attr("class", "states")
.selectAll("path")
.data(topojson.feature(mx, mx.objects.shp_vic).features)
.enter().append("path")
.attr("d", path)
.append("title")
.text(function(d) { return d.properties.NOM_ENT; });
});
d3.select(self.frameElement).style("height", height + "px");
</script>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment