Skip to content

Instantly share code, notes, and snippets.

@FrieseWoudloper
Created September 14, 2019 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrieseWoudloper/412ae7c0afc0fabf9cdbbb6e2045f2ee to your computer and use it in GitHub Desktop.
Save FrieseWoudloper/412ae7c0afc0fabf9cdbbb6e2045f2ee to your computer and use it in GitHub Desktop.
Zonder turf in d3v3
<!DOCTYPE html>
<head>
<style>
path {
fill: #ccc;
stroke: #fff;
stroke-width: .5px;
}
path:hover {
fill: orange;
}
div.tooltip {
position: absolute;
text-align: center;
width: 100%;
height: 14px;
padding: 2px;
font: 12px sans-serif;
background: #fff;
border: 0px;
pointer-events: none;
white-space: nowrap;
}
</style>
</head
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<div class="graph"></div>
<script>
var w = 600;
var h = 400;
//setup our display area
var svg = d3.select("#"+divName)
.append('svg')
.attr('w',w+'px')
.attr('h',h+'px');
var projection = d3.geo.mercator()
.translate([w/2, h/2]);
// .scale([500]);
var path = d3.geo.path()
.projection(projection);
//load the data
//url = "https://gist.githubusercontent.com/michellechandra/0b2ce4923dc9b5809922/raw/a476b9098ba0244718b496697c5b350460d32f99/us-states.json"
url = "https://geodata.nationaalgeoregister.nl/cbsgebiedsindelingen/wfs?service=wfs&request=GetFeature&typeName=cbs_arrondissementsgebied_2019_gegeneraliseerd&outputFormat=json&srsName=EPSG:4326";
d3.json(url, function(json) {
svg.selectAll('path')
.data(json.features)
.enter()
.append("path")
.attr('d', path);
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment