Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Basic GeoJSON map in D3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!doctype html>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Maps in D3js</title>
<meta name="description" content="Maps in d3js">
<meta name="author" content="Edward Mac Gillavry">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="d3js">
<link rel="shortcut icon" href="">
body {
background-color: #fffaf5;
svg {
background-color: #fffaf5;
.gemeente {
fill: #ccc;
stroke-width: 0.4;
stroke: #fff;
<script src=""></script>
let width = 450,
height = 600,
svg ="body")
.attr('width', width)
.attr('height', height);
d3.json("gemeenten2017.geojson", function(error, gemeenten) {
if (error) throw error;
let projection = d3.geoMercator()
.fitSize([width, height], gemeenten);
let path = d3.geoPath()
.attr("d", path)
.text(function(d) { return});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment