[ Launch: simple globe ] 4693544 by enjalot
-
-
Save enjalot/4693544 to your computer and use it in GitHub Desktop.
simple globe
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":"simple globe","endpoint":"","display":"svg","public":true,"require":[{"name":"topojson","url":"http://d3js.org/topojson.v0.min.js"},{"name":"d3.geo.projection","url":"http://d3js.org/d3.geo.projection.v0.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"world110.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}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"fullscreen":false,"thumbnail":"http://i.imgur.com/4WqR8xH.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
//http://bl.ocks.org/4188334 | |
var world = tributary.world110; | |
var philaLat = 39.88 // 39.88 N | |
var philaLng = -75.25 // 75.23 W | |
var globe = {type: "Sphere"}, | |
countries = topojson.object(world, world.objects.countries).geometries; | |
//center of the page | |
var center = [tributary.sw/2, tributary.sh/2]; | |
//var projection = d3.geo.mercator() | |
var projection = d3.geo.albers() | |
.scale(774) | |
.translate(center) | |
; | |
var xy = projection([philaLng, philaLat]) | |
var path = d3.geo.path() | |
.projection(projection); | |
var colorScale = d3.scale.ordinal() | |
.range([ | |
"#389934", | |
]) | |
var svg = d3.select("svg"); | |
console.log(xy) | |
var g = svg.append("g") | |
.classed("map", true) | |
//center the map by calculating the offset of our point | |
.attr("transform", "translate(" + [center[0]-xy[0], center[1]-xy[1]] + ")") | |
g.selectAll("path.country") | |
.data(countries) | |
.enter() | |
.append("path") | |
.attr("d", path) | |
.style("fill", function(d,i) { return colorScale(i) }) | |
.style("stroke", "#000000"); | |
g.append("circle") | |
.attr({ | |
cx: xy[0], | |
cy: xy[1], | |
r: 10 | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment