Skip to content

Instantly share code, notes, and snippets.

@will-s-t
Created November 15, 2015 21:54
Show Gist options
  • Select an option

  • Save will-s-t/4f0744601b7ecf50bc77 to your computer and use it in GitHub Desktop.

Select an option

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
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!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