-
-
Save Andrew-Reid/5852b69908feadab6b4048151e1179b1 to your computer and use it in GitHub Desktop.
USJSon
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> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v2.min.js"></script> | |
<script> | |
var w = 960, | |
h = 600; | |
var projection = d3.geoAlbersUsa(); | |
var path = d3.geoPath().projection(projection) | |
d3.json("https://bl.ocks.org/Andrew-Reid/raw/ddcda63d769f8e1d61fa5105346f983f/counties.json", function(error, us) { | |
if (error) throw error; | |
var svg = d3.select("body").append("svg") | |
.attr("width", w) | |
.attr("height", h); | |
svg.selectAll("path") | |
.data(topojson.feature(us, us.objects.states).features) | |
.enter().append("path") | |
.attr("class", "states") | |
.attr("d", path); | |
svg.append("path") | |
.attr("class", "state-borders") | |
.attr("d", path(topojson.mesh(us, us.objects.states))) | |
svg.append("path") | |
.attr("class", "county-borders") | |
.attr("d", path(topojson.mesh(us, us.objects.counties))); | |
aa = [-122.490402, 37.786453]; | |
bb = [-122.389809, 37.72728]; | |
svg.selectAll("circle") | |
.data([aa,bb]).enter() | |
.append("circle") | |
.attr("cx", function (d) { return projection(d)[0]; }) | |
.attr("cy", function (d) { return projection(d)[1]; }) | |
.attr("r", "8px") | |
.attr("fill", "red") | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment