Skip to content

Instantly share code, notes, and snippets.

@tarvaina
Created August 6, 2013 11:14
Show Gist options
  • Select an option

  • Save tarvaina/6163630 to your computer and use it in GitHub Desktop.

Select an option

Save tarvaina/6163630 to your computer and use it in GitHub Desktop.
World map practice
{"description":"World map practice","endpoint":"","display":"svg","public":true,"require":[{"name":"worldcountries","url":"https://raw.github.com/jinroh/d3experiments/master/world-50m.json"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"world.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":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/TbY9gXa.png"}
var countries = tributary.world;
var svg = d3.select('svg');
var colors = d3.scale.category20();
var projection = d3.geo.orthographic()
.translate([473, 283])
.scale(203)
.clipAngle(90)
.rotate([-21, -55]);
var geopath = d3.geo.path()
.projection(projection);
var countryShapes = svg.selectAll('.country').data(countries.features).enter()
.append('path')
.classed('country', true)
.attr({
d: function(d, i) { return geopath(d); },
fill: function(d, i) { return colors(i); },
stroke: "#000000",
'stroke-width': 0.5
});
navigator.geolocation.getCurrentPosition(function(d) {
var coord = projection([d.coords.longitude, d.coords.latitude]);
console.log(coord);
svg.append('circle')
.attr({
r: 4,
transform: "translate(" + coord + ")"
});
});
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment