This shows what happens when using the us county data json from http://bl.ocks.org/mbostock/4122298 with Datamaps. Rendering does work properly with https://raw.githubusercontent.com/jgoodall/us-maps/master/topojson/county.json, but it takes upwards of 10 seconds to draw.
Last active
August 29, 2015 14:24
-
-
Save dmachat/ff5ebd3be950d377586e to your computer and use it in GitHub Desktop.
Datamaps with U.S. Counties
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script src="http://rawgithub.com/markmarkoh/datamaps/master/dist/datamaps.none.min.js"></script> | |
<div id="counties" style="height: 500px; width: 900px;"></div> | |
<script> | |
var map = new Datamap({ | |
element: document.getElementById('counties'), | |
geographyConfig: { | |
dataUrl: 'us.json' | |
}, | |
scope: 'counties', | |
setProjection: function(element, options) { | |
var projection, path; | |
projection = d3.geo.albersUsa() | |
.scale(element.offsetWidth) | |
.translate([element.offsetWidth / 2, element.offsetHeight / 2 ]); | |
path = d3.geo.path() | |
.projection( projection ); | |
return {path: path, projection: projection}; | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment