UNPKG

earthjs

Version:

D3 Earth JS using SVG, Canvas & THREE js, build with some plugins.

35 lines (34 loc) 1.43 kB
<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/topojson.min.js"></script> <script type='text/javascript' src='../js/earthjs.js'></script> </head> <body> <svg id="earth-js"/> <canvas class="ej-canvas"></canvas> <script> const {offsetWidth, offsetHeight} = d3.select('body').node(); const g = earthjs({width: offsetWidth, height: offsetHeight, padding:5, transparent: true}) .register(earthjs.plugins.inertiaPlugin()) .register(earthjs.plugins.hoverCanvas()) .register(earthjs.plugins.canvasPlugin()) .register(earthjs.plugins.oceanSvg()) .register(earthjs.plugins.worldCanvas('../d/world-110m.json')) .register(earthjs.plugins.countryTooltipCanvas('../d/world-110m-country-names.tsv')); g.canvasPlugin.selectAll('.ej-canvas'); g._.options.showSelectedCountry = true; g.countryTooltipCanvas.show = function(props, tooltip) { const title = '<h3>Country:</h3>'+ Object.keys(props).map(k => k+': '+props[k]).join('<br/>'); return tooltip.html(title); }; g.ready(function() { const world = g.worldCanvas.data(); g.hoverCanvas.data(world); g.create(); }) </script> </body> </html>