earthjs
Version:
D3 Earth JS using SVG, Canvas & THREE js, build with some plugins.
42 lines (40 loc) • 1.66 kB
HTML
<html>
<head>
<meta charset="utf-8">
<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/topojson.min.js"></script>
<script type='text/javascript' src='../js/earthjs.js'></script>
</head>
<body>
<svg id="earth-js"></svg>
<script>
const {offsetWidth, offsetHeight} = d3.select('body').node();
const g = earthjs({width: offsetWidth, height: offsetHeight, padding:5, transparent: true})
.register(earthjs.plugins.autorotatePlugin())
.register(earthjs.plugins.inertiaPlugin())
.register(earthjs.plugins.dropShadowSvg())
.register(earthjs.plugins.oceanSvg())
.register(earthjs.plugins.graticuleSvg())
.register(earthjs.plugins.fauxGlobeSvg())
.register(earthjs.plugins.worldSvg('../d/world-110m.json'))
.register(earthjs.plugins.placesSvg('../d/places.json'))
.register(earthjs.plugins.barSvg('../data/bars.json'))
.register(earthjs.plugins.countryTooltipSvg('../d/world-110m-country-names.tsv'))
.register(earthjs.plugins.barTooltipSvg());
g.barSvg.ready = function(err, json) {
json.features.forEach(d => d.geometry.value = d.properties.mag);
g.barSvg.data(json);
};
g.ready(function(){
g.register(earthjs.plugins.centerSvg());
g.centerSvg.focused(function() {
g.autorotatePlugin.stop();
options.spin = false;
})
g.create();
})
</script>
</body>
</html>