Skip to content

Instantly share code, notes, and snippets.

@tomstove
Last active December 16, 2015 15:39
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 tomstove/5457494 to your computer and use it in GitHub Desktop.
Save tomstove/5457494 to your computer and use it in GitHub Desktop.
Tørshavn, Faroe Islands
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.
<!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>
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.
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.
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.
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