Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created July 6, 2014 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/965132f22675db8bdc6b to your computer and use it in GitHub Desktop.
Save enjalot/965132f22675db8bdc6b to your computer and use it in GitHub Desktop.
airports example topojson v1
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{"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"}
// 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