Last active
January 11, 2019 08:34
-
-
Save john-friedman/ab5318da4e57f954b83b33a5db4eaef9 to your computer and use it in GitHub Desktop.
Map test
This file contains hidden or 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"></script> | |
<script src="https://d3js.org/topojson.v1.min.js"></script> | |
<script src="https://rawgithub.com/markmarkoh/datamaps/master/dist/datamaps.none.min.js"></script> | |
<div id="afghan" style="height: 500px; width: 900px;"></div> | |
<script> | |
var map = new Datamap({ | |
element: document.getElementById('afghan'), | |
geographyConfig: { | |
dataUrl: 'https://gist.githubusercontent.com/markmarkoh/8856417/raw/9d9d64203f196206ea53034c1d1ea49520fef37a/customAfghanMap.topo.json' | |
}, | |
scope: 'afghan', | |
fills: { | |
defaultFill: '#e122', | |
someKey: '#fa0fa0' | |
}, | |
data: { | |
'AFG-1759': {fillKey: 'someKey'}, | |
'AFG-1747': {fillKey: 'someKey'} | |
}, | |
setProjection: function(element) { | |
var projection = d3.geo.mercator() | |
.center([66.166667, 34.4444]) | |
.scale(2200) | |
.translate([element.offsetWidth / 2, element.offsetHeight / 2]); | |
var 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