D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
bartlf
Full window
Github gist
D3-course-oct-2015-mod3-Netherlands
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>The Netherlands | Mercator projection</title> <script type="text/javascript" src="//d3js.org/d3.v3.min.js" charset="utf-8"></script> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <h1>The Netherlands</h1> <p>GIS-data source: <a href="https://diva-gis.org/gdata" target="_blank">Diva-gis.org</a></p> <script type="text/javascript"> //Width and height var w = 580; var h = 650; //Define map projection var projection = d3.geo.mercator() .center([ 5.4, 52.2 ]) .translate([ w/2, h/2 ]) .scale([ w*13]); //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("statplanet-neth.json", function(json) { //Bind data and create one path per GeoJSON feature svg.selectAll("path") .data(json.geometries) .enter() .append("path") .attr("d", path) .attr("class","munic"); }); </script> </body> </html>
https://d3js.org/d3.v3.min.js