Created
October 3, 2014 13:14
-
-
Save maggie-lee/81587b3928bf42ba8f27 to your computer and use it in GitHub Desktop.
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> | |
<meta charset="utf-8"> | |
<style> | |
#brookhaven1 { | |
fill: purple; | |
opacity: 0.8; | |
} | |
#dekalb_county { | |
fill: none; | |
} | |
/* CSS goes here. */ | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script> | |
var width = 2000, | |
height = 1500; | |
var scale = 150000; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var color = d3.scale.category20(); | |
var projection = d3.geo.mercator() | |
.scale(scale) | |
.rotate([84.4, -33.9, 0]); | |
var path = d3.geo.path() | |
.projection(projection); | |
// EXISTING CITIES EXCEPT BROOKHAVEN | |
d3.json("topo_cities.json", function(error, dek) { | |
if (error) return console.error(error); | |
console.log("ok dek:", dek); | |
svg.selectAll("#cities") | |
.data(topojson.feature(dek, dek.objects['cities']).features) | |
.enter().append("path") | |
.attr("id", function (d, i) {return "cities" + i; }) | |
.attr("d", path) | |
.attr("fill", function (d, i) {return color(i);}) | |
.attr("opacity", 0.8); | |
}); | |
// BROOKHAVEN | |
d3.json("topo_brookhaven.json", function(error, bkh) { | |
if (error) return console.error(error); | |
console.log("ok dek:", bkh); | |
svg.selectAll("#brookhaven") | |
.data(topojson.feature(bkh, bkh.objects['brookhaven']).features) | |
.enter().append("path") | |
.attr("id", function (d, i) {return "brookhaven" + i; }) | |
.attr("d", path) | |
.attr("opacity", 0) | |
.attr("stroke", "black") | |
.attr("stroke-width", "0.5px"); | |
}); | |
// DEKALB COUNTY OUTLINE | |
d3.json("topo_dekalb.json", function(error, dekalb) { | |
if (error) return console.error(error); | |
console.log("ok topo_dekalb:" , dekalb ) | |
svg.selectAll("#dekalb_county") | |
.data(topojson.feature(dekalb, dekalb.objects['dekalb_county']).features) | |
.enter().append("path") | |
.attr("id", "dekalb_county") | |
.attr("d", path) | |
.attr("stroke", "black") | |
.attr("stroke-width", "1px"); | |
}); | |
// INTERSTATES | |
d3.json("topo_hiways.json", function(error, roads) { | |
if (error) return console.error(error); | |
console.log("ok roads:", roads) | |
svg.selectAll("#roads") | |
.data(topojson.feature(roads, roads.objects['hiways']).features) | |
.enter().append("path") | |
.attr("id", function (d, i) {return "roads" + i; }) | |
.attr("d", path) | |
.attr("stroke", "black") | |
.attr("stroke-width", "0.5px") | |
.attr("opacity", 1); | |
}); | |
// SECONDARY ROADS | |
d3.json("topo_roads.json", function(error, roads) { | |
if (error) return console.error(error); | |
console.log("ok roads:", roads) | |
svg.selectAll("#roads") | |
.data(topojson.feature(roads, roads.objects['roads4']).features) | |
.enter().append("path") | |
.attr("id", function (d, i) {return "roads" + i; }) | |
.attr("d", path) | |
.attr("stroke", "black") | |
.attr("stroke-width", "0.5px") | |
.attr("opacity", 1); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment