UNPKG

earthjs

Version:

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

38 lines (36 loc) 1.36 kB
<html> <head> <style media="screen"> .input-area { position: absolute; z-index: 5; } </style> <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> <div class="input-area"> <button onclick="toMap()">To Map</button> <button onclick="toGlobe()">To Globe</button> </div> <svg id="earth-js" class="e1"></svg> <script> const {offsetWidth, offsetHeight} = d3.select('body').node(); const g = earthjs({width: offsetWidth, height: offsetHeight, padding:5, transparent: true}) g.register(earthjs.plugins.inertiaPlugin()); g.register(earthjs.plugins.graticuleSvg()); g.register(earthjs.plugins.worldSvg('../d/world-110m.json')); g.register(earthjs.plugins.countryTooltipSvg('../d/world-110m-country-names.tsv')); g.register(earthjs.plugins.flattenSvg()); g.register(earthjs.plugins.centerSvg()); g.ready(function(){ g.create(); }) function toMap() {g.flattenSvg.toMap();} function toGlobe() {g.flattenSvg.toGlobe();} </script> </body> </html>