Last active
December 16, 2015 15:39
-
-
Save tomstove/5457494 to your computer and use it in GitHub Desktop.
Tørshavn, Faroe Islands
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> | |
<style> | |
.buildings { | |
fill: steelblue; | |
} | |
.roads { | |
fill: none; | |
stroke: orange; | |
stroke-width: 0.3px; | |
} | |
.natural { | |
fill: green; | |
fill-opacity: 0.5; | |
} | |
.landuse { | |
fill: #aaa; | |
fill-opacity: 0.1; | |
} | |
.waterways { | |
fill: none; | |
stroke: steelblue; | |
stroke-width: 0.3px; | |
} | |
</style> | |
</head> | |
<body> | |
<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.v0.min.js"></script> | |
<script> | |
// -6.8321228027 61.9868792191 -6.7308425903 62.0522763224 | |
// -6.7814826964999995, 62.01957777075 | |
var width = 960, | |
height = 500; | |
var projection = d3.geo.mercator() | |
.translate([width/2, height/2]) | |
.center([-6.7814826964999995, 62.01957777075]) | |
.scale(700000); | |
var path = d3.geo.path() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var buildings = svg.append("g"); | |
var roads = svg.append("g"); | |
var natural = svg.append("g"); | |
var landuse = svg.append("g"); | |
var waterways = svg.append("g"); | |
d3.json('buildings.json', function(err, data) { | |
buildings.selectAll("path") | |
.data(data.features) | |
.enter().append("path") | |
.attr("class", "buildings") | |
.attr("d", path); | |
}); | |
d3.json('roads.json', function(err, data) { | |
roads.selectAll("path") | |
.data(data.features) | |
.enter().append("path") | |
.attr("class", "roads") | |
.attr("d", path); | |
}); | |
d3.json('natural.json', function(err, data) { | |
natural.selectAll("path") | |
.data(data.features) | |
.enter().append("path") | |
.attr("class", "natural") | |
.attr("d", path); | |
}); | |
d3.json('landuse.json', function(err, data) { | |
landuse.selectAll("path") | |
.data(data.features) | |
.enter().append("path") | |
.attr("class", "landuse") | |
.attr("d", path); | |
}); | |
d3.json('waterways.json', function(err, data) { | |
waterways.selectAll("path") | |
.data(data.features) | |
.enter().append("path") | |
.attr("class", "waterways") | |
.attr("d", path); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment