Advertisement
Guest User

Untitled

a guest
Nov 26th, 2017
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <meta charset="utf-8">
  3. <body>
  4. <script src="http://d3js.org/d3.v3.min.js"></script>
  5.     <script src="http://d3js.org/topojson.v1.min.js"></script>
  6.     <!-- I recommend you host this file on your own, since this will change without warning -->
  7.     <script src="http://datamaps.github.io/scripts/datamaps.usa.min.js?v=1"></script>
  8.     <div id="container1" style="position: relative; width: 80%; max-height: 80%;"></div>
  9.  
  10.          
  11.         <script>
  12.             function sleep(ms) {
  13.                 return new Promise(resolve => setTimeout(resolve, ms));
  14.             }
  15.             var lineFadeTime = 120000;
  16.             var lineDrawTime = 850;
  17.              //basic map config with custom fills, mercator projection
  18.             async function demo(){
  19.             var map = new Datamap({
  20.                 scope: 'usa',
  21.                 element: document.getElementById('container1'),
  22.                 projection: 'mercator',
  23.                 height: 1000,
  24.                 width: 1920,
  25.                 fills: {
  26.                     defaultFill: 'blue',
  27.                     lt50: 'rgba(0,244,244,0.9)',
  28.                     gt50: 'red'
  29.                 },
  30.             })
  31.             // map.arc([
  32.             // {
  33.             //  origin: {
  34.             //      latitude: 37.618889,
  35.             //      longitude: -122.375
  36.             //  },
  37.             //  destination: {
  38.             //      latitude: 30.194444,
  39.             //      longitude: -97.67
  40.             //  }
  41.             // }
  42.             // ], {strokeWidth: 5, animationSpeed: 850});
  43.  
  44.             var arcs = [
  45.                 {
  46.                     origin: {
  47.                         latitude: 64.2008,
  48.                         longitude: -149.4937
  49.                     },
  50.                     destination: {
  51.                         latitude: 21.289373,
  52.                         longitude: -157.917480
  53.                     }
  54.                 },
  55.                 {
  56.                     origin: {
  57.                         latitude: 37.618889,
  58.                         longitude: -122.375
  59.                     },
  60.                     destination: {
  61.                         latitude: 30.194444,
  62.                         longitude: -97.67
  63.                     }
  64.                 }
  65.             ];
  66.  
  67.             map.arc(arcs, {strokeWidth: 2});
  68.  
  69.             map.svg.selectAll('path.datamaps-arc').attr("opacity", 1);
  70.             // map.svg.selectAll('path.datamaps-arc').transition().duration(30000).style("opacity", 0);
  71.             // map.svg.selectAll('path.datamaps-arc').transition().delay(30000).remove();
  72.  
  73.             await sleep(10000);
  74.  
  75.             arcs.push({
  76.                 origin: {
  77.                     latitude: 27.6648,
  78.                     longitude: -81.5158
  79.                 },
  80.                 destination: {
  81.                     latitude: 43.8041,
  82.                     longitude: -120.5542
  83.                 }
  84.             });
  85.         }
  86.             demo();
  87.  
  88.  
  89.         </script>
  90. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement