This example demonstrates encoding a MultiPoint geometry object using TopoJSON.
Last active
August 1, 2016 02:02
-
-
Save mbostock/4408297 to your computer and use it in GitHub Desktop.
TopoJSON Points
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
license: gpl-3.0 |
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> | |
path { | |
stroke-linejoin: round; | |
} | |
.land { | |
fill: #ddd; | |
} | |
.states { | |
fill: none; | |
stroke: #fff; | |
} | |
</style> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script src="//d3js.org/queue.v1.min.js"></script> | |
<script src="//d3js.org/topojson.v1.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500; | |
var projection = d3.geo.albers(); | |
var path = d3.geo.path() | |
.projection(projection) | |
.pointRadius(1.5); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
queue() | |
.defer(d3.json, "/mbostock/raw/4090846/us.json") | |
.defer(d3.json, "airports.json") | |
.await(ready); | |
function ready(error, us, airports) { | |
if (error) throw error; | |
svg.append("path") | |
.datum(topojson.feature(us, us.objects.land)) | |
.attr("class", "land") | |
.attr("d", path); | |
svg.append("path") | |
.datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; })) | |
.attr("class", "states") | |
.attr("d", path); | |
svg.append("path") | |
.datum(topojson.feature(airports, airports.objects.airports)) | |
.attr("class", "points") | |
.attr("d", path); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment