Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Forked from pachevalier/datamaps.html
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markmarkoh/10900301 to your computer and use it in GitHub Desktop.
Save markmarkoh/10900301 to your computer and use it in GitHub Desktop.
Datamaps with custom data and custom projection
<!DOCTYPE html>
<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://datamaps.github.io/scripts/datamaps.none.min.js"></script>
<div id="container" style="position: relative; width: 500px; height: 300px;"></div>
<script>
var map = new Datamap({
element: document.getElementById('container'),
geographyConfig: {
dataUrl: 'mx_states.json'
},
scope: "states",
setProjection: function(element, options) {
var projection = d3.geo.equirectangular()
.center([-97, 25])
.rotate([4.4, 0])
.scale(800)
.translate([element.offsetWidth / 2, element.offsetHeight / 2]);
var path = d3.geo.path()
.projection(projection);
return {path: path, projection: projection};
}
});
</script>
</body>
</html>
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment