Skip to content

Instantly share code, notes, and snippets.

@zanarmstrong
Last active December 10, 2015 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanarmstrong/5c7678b44072388e40ed to your computer and use it in GitHub Desktop.
Save zanarmstrong/5c7678b44072388e40ed to your computer and use it in GitHub Desktop.
Map of Europe - for Migrant project
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: #ccc;
stroke: #fff;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 500;
var projection = d3.geo.orthographic()
.translate([width / 2, height / 2])
.scale(170)
.rotate([-15,-40,0])
.clipAngle(40)
.precision(0.6);
var path = d3.geo.path().projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("world.json", function(error, world) {
console.log(world)
if (error) throw error;
svg.append("path")
.datum(topojson.feature(world, world.objects.ne_110m_land))
.attr("d", path);
var citiesData = [{"city": "Stockholm", location: {"lat": 59.3294, "long": 18.0686}}];
svg.append("circle")
.attr("r", 110)
.attr("cx", width/2)
.attr("cy", height/2)
.attr("fill", "none")
.attr("stroke", "grey")
svg.append("g")
.attr("class", "cities")
.selectAll(".cityDot")
.data(citiesData)
.enter().append("circle")
.attr("class", "cityDot")
.attr("transform", function(d) {
return "translate(" + projection([
d.location.long,
d.location.lat
]) + ")"
})
.attr("r", 3)
.attr("fill", "red");
});
</script>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment