1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
| <div id='fatherobj2'> <canvas id='quakeCanvas2'></canvas> </div> <script type='text/javascript' src='https://uipv4.zywvvd.com:33030/HexoFiles/js/planetaryjs/d3.v3.min.js'></script> <script type='text/javascript' src='https://uipv4.zywvvd.com:33030/HexoFiles/js/planetaryjs/topojson.v1.min.js'></script> <script type='text/javascript' src='https://uipv4.zywvvd.com:33030/HexoFiles/js/planetaryjs/planetaryjs.min.js'></script> <script type='text/javascript' src='https://uipv4.zywvvd.com:33030/HexoFiles/js/planetaryjs/moment.min.js'></script> <script> (function() { var canvas = document.getElementById('quakeCanvas2'); var board_obj = document.getElementById('fatherobj2'); var planet = planetaryjs.planet(); planet.loadPlugin(autocenter({extraHeight: -120})); planet.loadPlugin(autoscale({extraHeight: -120})); planet.loadPlugin(planetaryjs.plugins.earth({ topojson: { file: 'https://uipv4.zywvvd.com:33030/HexoFiles/js/planetaryjs/world-110m.json' }, oceans: { fill: '#001320' }, land: { fill: '#06304e' }, borders: { stroke: '#001320' } })); planet.loadPlugin(planetaryjs.plugins.pings()); planet.loadPlugin(planetaryjs.plugins.zoom({ scaleExtent: [50, 5000] })); planet.loadPlugin(planetaryjs.plugins.drag({ onDragStart: function() { this.plugins.autorotate.pause(); }, onDragEnd: function() { this.plugins.autorotate.resume(); } })); planet.loadPlugin(autorotate(5)); planet.projection.rotate([100, -10, 0]); planet.draw(canvas); var colors = d3.scale.pow() .exponent(3) .domain([2, 4, 6, 8, 10]) .range(['white', 'yellow', 'orange', 'red', 'purple']); var angles = d3.scale.pow() .exponent(3) .domain([2.5, 10]) .range([0.5, 15]); var ttls = d3.scale.pow() .exponent(3) .domain([2.5, 10]) .range([2000, 5000]); d3.select('#magnitudes').selectAll('li') .data(colors.ticks(9)) .enter() .append('li') .style('color', colors) .text(function(d) { return "Magnitude " + d; }); d3.json('https://uipv4.zywvvd.com:33030/HexoFiles/js/planetaryjs/year_quakes_small.json', function(err, data) { if (err) { alert("Problem loading the quake data."); return; } var start = parseInt(data[0].time, 10); var end = parseInt(data[data.length - 1].time, 10); var currentTime = start; var lastTick = new Date().getTime(); var updateDate = function() { d3.select('#date').text(moment(currentTime).utc().format("MMM DD YYYY HH:mm UTC")); }; var percentToDate = d3.scale.linear() .domain([0, 100]) .range([start, end]); var realToData = d3.scale.linear() .domain([0, 1000 * 60 * 12]) .range([0, end - start]); var paused = false; d3.select('#slider') .on('change', function(d) { currentTime = percentToDate(d3.event.target.value); updateDate(); }) .call(d3.behavior.drag() .on('dragstart', function() { paused = true; }) .on('dragend', function() { paused = false; }) ); d3.timer(function() { var now = new Date().getTime(); if (paused) { lastTick = now; return; } var realDelta = now - lastTick; if (realDelta > 500) realDelta = 500; var dataDelta = realToData(realDelta); var toPing = data.filter(function(d) { return d.time > currentTime && d.time <= currentTime + dataDelta; }); for (var i = 0; i < toPing.length; i++) { var ping = toPing[i]; planet.plugins.pings.add(ping.lng, ping.lat, { angle: angles(ping.mag), color: colors(ping.mag), ttl: ttls(ping.mag) }); } currentTime += dataDelta; if (currentTime > end) currentTime = start; updateDate(); d3.select('#slider').property('value', percentToDate.invert(currentTime)); lastTick = now; });
}); function autocenter(options) { options = options || {}; var needsCentering = false; var globe = null; var resize = function() { var width = board_obj.offsetWidth; var height = board_obj.offsetWidth; globe.canvas.width = width; globe.canvas.height = height; globe.projection.translate([width / 2, height / 2]); }; return function(planet) { globe = planet; planet.onInit(function() { needsCentering = true; d3.select(window).on('resize', function() { needsCentering = true; }); }); planet.onDraw(function() { if (needsCentering) { resize(); needsCentering = false; } }); }; }; function autoscale(options) { options = options || {}; return function(planet) { planet.onInit(function() { var width = board_obj.offsetWidth; var height = board_obj.offsetWidth; planet.projection.scale(Math.min(width, height) / 2.3); }); }; }; function autorotate(degPerSec) { return function(planet) { var lastTick = null; var paused = false; planet.plugins.autorotate = { pause: function() { paused = true; }, resume: function() { paused = false; } }; planet.onDraw(function() { if (paused || !lastTick) { lastTick = new Date(); } else { var now = new Date(); var delta = now - lastTick; var rotation = planet.projection.rotate(); rotation[0] += degPerSec * delta / 1000; if (rotation[0] >= 180) rotation[0] -= 360; planet.projection.rotate(rotation); lastTick = now; } }); }; }; })(); </script>
|