Last active
August 29, 2015 14:16
-
-
Save milafrerichs/9bb6571557b881126d40 to your computer and use it in GitHub Desktop.
Simple Map of Europe
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> | |
<meta charset="utf-8"> | |
<style> | |
#map { | |
width: 800px; | |
height: 400px; | |
} | |
</style> | |
<body> | |
<div id="map"></div> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/d3.geo.projection.v0.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script> | |
(function() { | |
var center, countries, height, path, projection, scale, svg, width; | |
width = 800; | |
height = 400; | |
center = [5, 70]; | |
scale = 600; | |
projection = d3.geo.mercator().scale(scale).translate([width / 2, 0]).center(center); | |
path = d3.geo.path().projection(projection); | |
svg = d3.select("#map").append("svg").attr("height", height).attr("width", width); | |
countries = svg.append("g"); | |
d3.json("eu.geojson", function(data) { | |
return countries.selectAll('.country').data(data.features).enter().append('path').attr('class', 'country').attr('d', path); | |
}); | |
}).call(this); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment