Created
November 10, 2015 18:14
-
-
Save octaviomtz/fd98fd00bd1e6ad31730 to your computer and use it in GitHub Desktop.
map of México
This file contains 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> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Howework 1 | Octavio</title> | |
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="script.js"></script> | |
<style type="text/css"> | |
body { | |
margin: 0; | |
background-color: #bbbbbb; | |
font-family: Helvetica, Arial, sans-serif; | |
} | |
#container { | |
width: 800px; | |
margin-left: auto; | |
margin-right: auto; | |
margin-top: 50px; | |
padding: 50px; | |
background-color: #ffffff; | |
box-shadow: 3px 3px 5px 6px #000; | |
} | |
#title { | |
width: 800px; | |
margin-left: auto; | |
margin-right: auto; | |
} | |
#someText { | |
width: 800px; | |
margin-left: auto; | |
margin-right: auto; | |
font-family: Helvetica, Arial, sans-serif; | |
} | |
</style> | |
</head> | |
<body> | |
<h1 id="title">Map of México </h1> | |
<div id="container"></div> | |
<div id="someText"> | |
<p>The .shp file was obtained from <a href="http://www.numeroslocos.com/2013/07/10/shapefile/">here</a> and converted in mapshaper.org | |
</p> | |
</div> | |
<script src="script.js"></script> | |
</body> | |
</html> |
This file contains 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
//Width and height | |
var w = 500; | |
var h = 500; | |
//Define map projection | |
var projection = d3.geo.mercator() | |
.center([-86, 5]) | |
.translate([w, h]) | |
.scale([w * 1.8]); | |
//Define path generator | |
var path = d3.geo.path() | |
.projection(projection); | |
//Create SVG | |
var svg = d3.select("#container") | |
.append("svg") | |
.attr("width", w) | |
.attr("height", h); | |
//Load in GeoJSON data | |
d3.json("national_estatal.json", function (json) { | |
//Bind data and create one path per GeoJSON feature | |
svg.selectAll("path") | |
.data(json.geometries) | |
.enter() | |
.append("path") | |
.attr("d", path) | |
.attr("fill", "#1A9112") | |
.attr("stroke", "#3s92114"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment