Skip to content

Instantly share code, notes, and snippets.

@tyramoss
Created November 10, 2015 14:37
Show Gist options
  • Save tyramoss/6fbbbd99df5343103621 to your computer and use it in GitHub Desktop.
Save tyramoss/6fbbbd99df5343103621 to your computer and use it in GitHub Desktop.
Module 3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Kaarten</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: #eeeeee;
font-family: Helvetica, Arial, sans-serif;
}
h1
{font-family: sans-serif;
font-weight: 100;
font-size: 20px;
color: #92CC50;
padding-left: 50px;
}
p
{font-family: sans-serif;
font-weight: 100;
font-size: 11px;
padding-left: 50px;
line-height: 15px;
}
a:link {
text-decoration: none;
color: #92CC50;
}
a:hover {
text-decoration: underline;
}
a:visited {
color: #92CC50;
}
a:active {
color: #92CC50;
}
path:hover {
fill: #ffffff;
}
text
{font-family: sans-serif;
font-size: 9px;
}
svg {
background-color: white;
}
#container {
width: 600px;
margin-left: auto;
margin-right: auto;
margin-top: 25px;
padding: 25px;
background-color: white;
box-shadow: 1px 1px 1px 1px #ccc;
}
path {
stroke: white;
stroke-width: 0.5;
fill: #F4E7D3;
}
</style>
</head>
<body>
<div id="container">
<h1>Kaart van Nederland</h1>
<p>Dit is de kaart van Nederland gemaakt in d3.js. </p>
<p>Bronnen: <a href="http://www.statsilk.com">Statsilk</a>, 2015</p>
</div>
<script type="text/javascript">
//Width and height
var w = 500;
var h = 500;
//Define map projection
var projection = d3.geo.mercator()
.center([ 5, 53])
.translate([ w/2, 100 ])
.scale([ 6000 ]);
//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("nl3.json", function(json) {
//Bind data and create one path per GeoJSON feature
svg.selectAll("path")
.data(json.geometries)
.enter()
.append("path")
.attr("d", path);
});
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
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