Created
November 28, 2018 13:04
-
-
Save VincentRbbmnd/707dcd394dea3bfe75a17ca0f88a6299 to your computer and use it in GitHub Desktop.
NS API Spoortkaart JSON demo
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> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Data Visualization</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<script src="https://d3js.org/d3.v5.min.js"></script> | |
<script> | |
var width = 1400, | |
height = 800; | |
console.log('width: ', width) | |
console.log('height: ', height) | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
console.log('svg: ', svg) | |
var projection = d3.geoMercator() | |
.scale(6000) | |
.center([5,53]) | |
// .translate([width, height]); | |
console.log('projection: ', projection) | |
var path = d3.geoPath() | |
.projection(projection); | |
console.log('path: ', path) | |
d3.json("data/nl-provinces.geojson") | |
.then(function(data) { | |
console.log('data: ', data) | |
var provincies = data | |
svg.append("g") | |
.selectAll("path") | |
.data(provincies.features) | |
.enter().append("path") | |
.attr("d", path); | |
}); | |
d3.json("data/ns-spoorkaart.json").then(function(data) { | |
console.log('data: ', data) | |
var nsSporen = data.payload | |
svg.append("g") | |
.selectAll("path") | |
.data(nsSporen.features) | |
.enter().append("path") | |
.style('fill', 'red') | |
.attr("d", path); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment