[ Launch: airports example ] 9bb4b328e40d6708e83e by enjalot
-
-
Save enjalot/9bb4b328e40d6708e83e to your computer and use it in GitHub Desktop.
airports example
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
{"description":"airports example","endpoint":"","display":"svg","public":true,"require":[{"name":"topojson","url":"http://d3js.org/topojson.v0.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"airports.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"california.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"inline-console":true,"thumbnail":"http://i.imgur.com/n5gnVLq.png"} |
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
// tutorialhttp://bost.ocks.org/mike/map/ | |
var svg = d3.select("svg"); | |
var airports = tributary.airports; | |
var ca = tributary.california; | |
var california = topojson.object(ca, ca.objects.counties); | |
var width = tributary.sw; | |
var height = tributary.sh; | |
var center = { | |
x: width/2, | |
y: height/2 | |
} | |
var colorScale = d3.scale.category20(); | |
var lonlat = [-122.4376, 37.77]; | |
var projection = d3.geo.mercator() | |
//var projection = d3.geo.albers() | |
.center(lonlat) | |
.scale(15719) | |
.translate([width/2, height/2]) | |
var xy = projection(lonlat); | |
console.log(xy) | |
var path = d3.geo.path() | |
//.projection(null) | |
.projection(projection); | |
svg.append("path") | |
.attr("d", path(california)) | |
.classed("counties", true) | |
.style({ | |
fill: "none", | |
stroke: "#000" | |
}) | |
var points = topojson.object(airports, airports.objects.AirportFlty); | |
svg.selectAll("circle.airports") | |
.data(points.geometries) | |
.enter() | |
.append("circle").classed("airports", true) | |
.attr({ | |
cx: function(d) { var x = projection(d.coordinates)[0]; return x; }, | |
cy: function(d) { var y = projection(d.coordinates)[1]; return y; }, | |
r: 4 | |
}) | |
.style("fill", "#000") | |
.style("stroke", "#000") | |
.style("stroke-width", 3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment