earthjs
Version:
D3 Earth JS using SVG, Canvas & THREE js, build with some plugins.
37 lines (36 loc) • 1.41 kB
HTML
<html>
<head>
<link type="text/css" rel="stylesheet" href="../css/earthjs.css">
<script type='text/javascript' src="../js/d3.min.js"></script>
<script type='text/javascript' src='../js/three.min.js'></script>
<script type='text/javascript' src="../js/topojson.min.js"></script>
<script type='text/javascript' src='../js/earthjs.js'></script>
<style>body {background: #555;}</style>
</head>
<body>
<svg id="earth-js"></svg>
<canvas id="three-js"></canvas>
<script>
const {offsetWidth, offsetHeight} = d3.select('body').node();
const g = earthjs({width: offsetWidth, height: offsetHeight, padding:5})
.register(earthjs.plugins.inertiaPlugin())
.register(earthjs.plugins.hoverCanvas())
.register(earthjs.plugins.countryCanvas())
.register(earthjs.plugins.threejsPlugin())
.register(earthjs.plugins.canvasThreejs('../d/world-110m.json'))
.register(earthjs.plugins.autorotatePlugin());
g.canvasThreejs.style({ocean: '#36496e'});
g.canvasThreejs.ready = function(err, json) {
g.canvasThreejs.data(json);
g.countryCanvas.data(json);
g.hoverCanvas.data(json);
}
g._.options.showSelectedCountry = true;
// g._.options.coropleth = true;
g.ready(function(){
g.create();
})
</script>
</body>
</html>