[ Launch: airports example topojson v1 ] 965132f22675db8bdc6b by enjalot
[ Launch: airports example ] 9bb4b328e40d6708e83e by enjalot
-
-
Save enjalot/965132f22675db8bdc6b to your computer and use it in GitHub Desktop.
airports example topojson v1
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 topojson v1","endpoint":"","display":"svg","public":true,"require":[{"name":"topojson v1","url":"http://d3js.org/topojson.v1.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.feature(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.feature(airports, airports.objects.AirportFlty); | |
svg.selectAll("circle.airports") | |
.data(points.features) | |
.enter() | |
.append("circle").classed("airports", true) | |
.attr({ | |
cx: function(d) { var x = projection(d.geometry.coordinates)[0]; return x; }, | |
cy: function(d) { var y = projection(d.geometry.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