-
-
Save alx-developer/d95fe0c64ab61f5c93e45dab2789f0c4 to your computer and use it in GitHub Desktop.
Topojson of Mexican municipalities and states
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <title>Mexico Topojson</title> | |
| <body> | |
| <script src="http://d3js.org/d3.v3.min.js"></script> | |
| <script src="http://d3js.org/topojson.v0.min.js"></script> | |
| <script> | |
| var x = d3.scale.linear() | |
| .domain([0, width]) | |
| .range([0, width]); | |
| var y = d3.scale.linear() | |
| .domain([0, height]) | |
| .range([height, 0]); | |
| var width = 960, | |
| height = 500; | |
| var projection = d3.geo.mercator() | |
| .scale(8500) | |
| .center([-102.34034978813841, 24.012062015793]); | |
| var svg = d3.select("body").append("svg") | |
| .attr("width", width) | |
| .attr("height", height); | |
| var g = svg.append("g"); | |
| d3.json("mx_tj.json", function(error, mx) { | |
| svg.selectAll("path") | |
| .data(topojson.object(mx, mx.objects.municipios2).geometries) | |
| .enter().append("path") | |
| .attr("d", d3.geo.path().projection(projection)) | |
| .attr("fill", "transparent") | |
| .style("stroke", "#333") | |
| .style("stroke-width", ".2px") | |
| .attr("class", "muns"); | |
| g.selectAll("path") | |
| .data(topojson.object(mx, mx.objects.estados2).geometries) | |
| .enter().append("path") | |
| .attr("d", d3.geo.path().projection(projection)) | |
| .attr("fill", "transparent") | |
| .style("stroke", "#333"); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment