D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
heathermkrause
Full window
Github gist
NCY Map
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Heather's NYC Map</title> <script type="text/javascript" src="//d3js.org/d3.v3.min.js"></script> <style type="text/css"> body { background-color: gray; } svg { background-color: white; } </style> </head> <body> <script type="text/javascript"> //Width and height var w = 700; var h = 400; //Define map projection var projection = d3.geo.mercator() .center([ -73.94, 40.70]) .translate([ w/2, h/2 ]) .scale([ 30000]); //Define path generator var path = d3.geo.path() .projection(projection); //Create SVG var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); //Load in GeoJSON data d3.json("NYCF.json", function(json) { //Bind data and create one path per GeoJSON feature svg.selectAll("path") .data(json.features) .enter() .append("path") .attr("d", path); }); </script> </body> </html>
https://d3js.org/d3.v3.min.js