Skip to content

Instantly share code, notes, and snippets.

@VincentRbbmnd
Created November 28, 2018 13:04
Show Gist options
  • Save VincentRbbmnd/707dcd394dea3bfe75a17ca0f88a6299 to your computer and use it in GitHub Desktop.
Save VincentRbbmnd/707dcd394dea3bfe75a17ca0f88a6299 to your computer and use it in GitHub Desktop.
NS API Spoortkaart JSON demo
<!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>
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.
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