A world map using a Kavrayskiy VII projection showing countries visited. Identified by international id codes. Created for madialexander.com.
Last active
December 26, 2015 15:29
-
-
Save darrenjaworski/7173571 to your computer and use it in GitHub Desktop.
World Map (Travels)
This file contains 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> | |
<head> | |
<title> | |
World Map - Travels | |
</title> | |
<!-- style --> | |
<style> | |
#globe, body, html { | |
height: 100%; | |
width: 100%; | |
} | |
.stroke { | |
fill: none; | |
stroke: #000; | |
stroke-width: 3px; | |
} | |
.graticule { | |
fill: none; | |
stroke: #0F2D40; | |
stroke-width: .5px; | |
stroke-opacity: .5; | |
} | |
.fill { | |
fill: #fff; | |
} | |
.land { | |
fill: #0F2D40; | |
} | |
.boundary { | |
fill: none; | |
stroke: #fff; | |
stroke-width: 1px; | |
} | |
</style> | |
<!-- javascript --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
<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 src="script.js"></script> | |
<script></script> | |
</head> | |
<body> | |
<div id="globe"></div> | |
</body> |
This file contains 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
$(document).ready( function() { | |
var width = parseInt($('#globe').css('width')); | |
var height = width * .604; | |
var color = d3.scale.category10(); | |
var projection = d3.geo.kavrayskiy7() | |
.scale(width * .177) | |
.translate([width / 2, height / 2]) | |
.precision(.1); | |
var path = d3.geo.path() | |
.projection(projection); | |
var graticule = d3.geo.graticule(); | |
var svg = d3.select("#globe").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("path") | |
.datum(graticule) | |
.attr("class", "graticule") | |
.attr("d", path); | |
d3.json("world.json", function(error, world) { | |
var countries = topojson.feature(world, world.objects.countries).features; | |
svg.selectAll(".country") | |
.data(countries) | |
.enter().insert("path", ".graticule") | |
.attr("class", "country") | |
.attr("d", path) | |
.style("fill", function(d){ | |
if( d.id == '388' || d.id == '124' || d.id == '634' || d.id == '784' || d.id == '792' || d.id == '724' || d.id == '620' ){ | |
return "#CFB705"; | |
} else if ( d.id == '840' ){ | |
return "#000" | |
} else { | |
return "#304959"; | |
} | |
}); | |
svg.insert("path", ".graticule") | |
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; })) | |
.attr("class", "boundary") | |
.attr("d", path); | |
}); | |
d3.select(self.frameElement).style("height", height + "px"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment