Skip to content

Instantly share code, notes, and snippets.

@xseignard
Created January 30, 2014 10:29
Show Gist options
  • Save xseignard/8705981 to your computer and use it in GitHub Desktop.
Save xseignard/8705981 to your computer and use it in GitHub Desktop.
indexed world map
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.
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="http://mbostock.github.com/d3/d3.js"></script><style type="text/css"></style><script src="http://d3js.org/d3.v2.js"></script>
</head>
<body>
<script type="text/javascript">
window.onload = function() {
var width = 800,
height = 500;
//Define path generator
var path = d3.geo.path().projection(d3.geo.mercator())
var svg = d3.select('body').append('svg')
.attr('width', width)
.attr('height', height);
var i = 0;
d3.json('countries.geo.json', function(json) {
svg.selectAll('path')
.data(json.features)
.enter()
.append('path')
.attr('id', function(d) { return d.id; })
.attr('d', path)
.attr('fill', function() {
var color = 'rgb('+i+','+i+','+i+')';
i++;
return color;
})
.append('svg:title')
.text(function(d) { return d.properties.name; });
});
};
</script>
</body>
</html>
@ljekidex
Copy link

Hi , I like this app it is nice but have in mind that Kosovo is Serbia !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment