Using d3.geo.albersUsa.
Last active
July 16, 2018 00:28
-
-
Save martgnz/ce8efee65a26e4677e5e5d3da2c8f1a7 to your computer and use it in GitHub Desktop.
US States
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
border: none | |
license: mit |
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="https://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<script src="https://d3js.org/topojson.v1.min.js"></script> | |
<script src="https://unpkg.com/d3-geo-projection@0.2.16/d3.geo.projection.min.js"></script> | |
<script src="https://unpkg.com/rbush@1.4.3/rbush.js"></script> | |
<script src="https://unpkg.com/spamjs@1.1.0/spam.min.js"></script> | |
<script type='text/javascript'> | |
var width = 960; | |
var height = 500; | |
d3.json("us-states.json", function(error, d) { | |
topojson.presimplify(d); | |
var map = new StaticCanvasMap({ | |
element: "body", | |
projection: d3.geo | |
.albersUsa() | |
.scale(1000) | |
.translate([width / 2, height / 2]), | |
data: [ | |
{ | |
features: topojson.feature(d, d.objects["states"]), | |
static: { | |
paintfeature: function(parameters, d) { | |
parameters.context.lineWidth = 1; | |
parameters.context.strokeStyle = "rgb(255,255,255)"; | |
parameters.context.fillStyle = "rgb(30, 30, 30)"; | |
parameters.context.stroke(); | |
parameters.context.fill(); | |
} | |
} | |
} | |
] | |
}); | |
map.init(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why isn't the US-atlas dataset drawn correctly by Spam?