Some kind of problem with generating the topojson from this geojson causes it to render incorrectly.
Last active
August 29, 2015 14:06
-
-
Save emeeks/6bc43691f631a4097d05 to your computer and use it in GitHub Desktop.
Topojson issue
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
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>Topojson Issue</title> | |
<meta charset="utf-8" /> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8" type="text/javascript"></script> | |
<script src="http://d3js.org/topojson.v1.min.js" type="text/javascript"> | |
</script> | |
</head> | |
<style> | |
html,body,div,svg { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
} | |
</style> | |
<script> | |
d3.json("worldstats.topojson", createTopo); | |
function createTopo(data) { | |
var countries = topojson.feature(data, data.objects.worldstats) | |
width = 500; | |
height = 500; | |
projection = d3.geo.mercator() | |
.scale(120) | |
.translate([width / 2, height / 2]) | |
.center([20,0]) | |
geoPath = d3.geo.path().projection(projection); | |
d3.select("svg").selectAll("path.countries").data(countries.features) | |
.enter() | |
.append("path") | |
.attr("d", geoPath) | |
.attr("class", "countries") | |
.style("fill", "rgba(122,122,0,.05)") | |
.style("stroke-width", 1) | |
.style("stroke", "black") | |
.style("opacity", .5) | |
} | |
</script> | |
<div id="map"> | |
<svg></svg> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment