Created
November 15, 2015 21:54
-
-
Save will-s-t/4f0744601b7ecf50bc77 to your computer and use it in GitHub Desktop.
Some bits of Europe and West Asia that I have data about
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Some bits of Europe and West Asia that I have data about</title> | |
| <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
| <script type="text/javascript"> | |
| function hideLoader() { | |
| // document.getElementById("loading").style.display = "none"; | |
| } | |
| </script> | |
| <style type="text/css"> | |
| body { | |
| margin: 0; | |
| background-color: white; | |
| font-family: Georgia, Times, serif; | |
| } | |
| #container { | |
| width: 100%; | |
| max-width: 750px; | |
| margin-left: auto; | |
| margin-right: auto; | |
| background-color: #FFF; | |
| margin-top: 50px; | |
| /*box-shadow: 3px 3px 5px 6px #bbb;*/ | |
| } | |
| h2 { | |
| text-align: center; | |
| font-size: 20px; | |
| font-weight: bold; | |
| padding-top: 15px; | |
| } | |
| /* #loading { | |
| position:absolute; | |
| text-align: center; | |
| margin-left: auto; | |
| margin-right: auto; | |
| max-width: 750px; | |
| width: 100%; | |
| font-size: 12px; | |
| font-weight: normal; | |
| padding-top: 15px; | |
| top: 200px; | |
| }*/ | |
| } | |
| </style> | |
| </head> | |
| <body onload="hideLoader()"> | |
| <div id="container"> | |
| <h2>Some bits of Europe and West Asia that I have data about</h2> | |
| <!-- <p id="loading">loading...</p> --> | |
| <section id="mapping"></section> | |
| </div> | |
| <script type="text/javascript"> | |
| //Width and height | |
| var w = 750; | |
| var h = 500; | |
| //make map smaller if window is smaller than 750px | |
| if (typeof window.innerWidth != 'undefined' && window.innerWidth < 750) { | |
| w = window.innerWidth; | |
| } | |
| window.onresize = function(){ location.reload(); } | |
| //Define map projection | |
| var projection = d3.geo.azimuthalEqualArea() | |
| .center([ 15, 50 ]) | |
| .translate([ w/2, h/2 ]) | |
| .scale([ w*1.4 ]); | |
| //Define path generator | |
| var path = d3.geo.path() | |
| .projection(projection); | |
| //Create SVG | |
| var svg = d3.select("#mapping") | |
| .append("svg") | |
| .attr("width", w) | |
| .attr("height", h); | |
| //Load in GeoJSON data | |
| d3.json("bitsofEU.json", function(json) { | |
| //Bind data and create one path per GeoJSON feature | |
| svg.selectAll("path") | |
| .data(json.features) | |
| .enter() | |
| .append("path") | |
| .attr("d", path) | |
| .attr("stroke", "white") | |
| .attr("stroke-width", "0.5") | |
| .attr("fill", "#CCC"); | |
| }); | |
| // document.getElementById("loading").style.display = "none"; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment