SHARE
TWEET

WorldWind Challenge

CrazyCrafthkl Aug 7th, 2017 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head lang="en">
  3.     <meta charset="UTF-8">
  4.     <header>
  5.     <title>World Wind Example</title>
  6.     <script src="http://worldwindserver.net/webworldwind/worldwind.min.js" type="text/javascript"></script>
  7. </head>
  8. <body>
  9. <h1 style="text-align: center; font-family: sans-serif;">The Fest App</h1>
  10. <div style="margin: auto; padding: 0; width: 50%">
  11.     <div style="width: 1024px; height: 768; border-style: solid; border-color: black;">
  12.         <canvas id="canvasOne" width="1024" height="768">
  13.             Your browser does not support HTML5 Canvas.
  14.         </canvas>
  15.     </div>
  16. </div>
  17. <script>
  18.     window.addEventListener("load", eventWindowLoaded, false);
  19.    
  20.     //You can easily add more events
  21.     var locations = [
  22.         //Event name, location, time, latitude, longitude, link
  23.         ["August Burns Red (USA), Countless Goodbyes", "Tavastia-klubi, Kamppi, Helsinki", "7.8.2017 20:00", 60.168532, 24.933190, "http://www.meteli.net/tapahtuma/291705"],
  24.         ["Beth Hart (USA)", "Kulttuuritalo, Alppila, Helsinki", "07.08.2017 19:30", 60.188345, 24.944266, "http://www.meteli.net/tapahtuma/298407"],
  25.         ["Hilland Mondays: Hilland Playboys feat. George Highfill (USA)", "Juttutupa/Marco Polo, Kallio, Helsinki", "07.08.2017 20:00", 60.178980, 24.947407, "http://www.meteli.net/tapahtuma/298830"],
  26.         ["Terassi Live: Stala Duo", "Santa Fé, Helsinki", "07.08.2017 21:00", 60.168964, 24.944842, "http://www.meteli.net/tapahtuma/299664"],
  27.         ["BRQ Vantaa Festival - His Masters Voice", "Pyhän Laurin kirkko ja kappeli, Vantaa", "07.08.2017 19:00", 60.283024, 24.984051, "http://www.meteli.net/tapahtuma/300373"],
  28.         ["BRQ Vantaa Festival - Keskeisiä Säveliä", "Pyhän Laurin kirkko ja kappeli, Vantaa", "07.08.2017 21:00", 60.282890, 24.983987, "http://www.meteli.net/tapahtuma/300376"],
  29.         ["Etno-Espa: Suistamon Sähkö", "Espan lava, Helsinki", "07.08.2017 16:00", 60.167715, 24.950296, "http://www.meteli.net/tapahtuma/300817"],
  30.         ["Beth Hart (USA)", "Gong, Turku", "08.08.2017 19:00", 60.450577, 22.258939, "http://www.meteli.net/tapahtuma/298272"],
  31.         ["Juha Tapio", "Kesäteatteri, Heinola", "08.08.2017 19:00", 61.201881, 26.028379, "http://www.meteli.net/tapahtuma/298791"],
  32.         ["Rauma Festivo - Ei vettä, rantaa rakkaampaa", "Rauma-sali, Rauma", "8.08.2017 19:00", 61.127839, 21.482008, "http://www.meteli.net/tapahtuma/299026"],
  33.         ["Terassi Live: Millie Jean Duo", "Santa Fé, Helsinki", "08.08.2017 21:00", 60.168967, 24.945222, "http://www.meteli.net/tapahtuma/299665"],
  34.         ["BRQ Vantaa Festival - Ilmaisun Mykkä Orja", "Pyhän Laurin kirkko ja kappeli, Vantaa", "08.08.2017 21:00", 60.283033, 24.984467, "http://www.meteli.net/tapahtuma/300043"],
  35.         ["Tunnelmatiistai -klubi: Joana & Bossakopla, Ylva Haru, Musta5", "Elmun Baari, Helsinki", "08.08.2017 18:00", 60.159653, 24.930776, "http://www.meteli.net/tapahtuma/300228"],
  36.        
  37.     ];
  38.    
  39.     function eventWindowLoaded () {
  40.         WorldWind.Logger.setLoggingLevel(WorldWind.Logger.LEVEL_ERROR);
  41.         var wwd = new WorldWind.WorldWindow("canvasOne");
  42.  
  43.         var layers = [
  44.             {layer: new WorldWind.BMNGLayer(), enabled: true},
  45.             {layer: new WorldWind.BMNGLandsatLayer(), enabled: false},
  46.             {layer: new WorldWind.BingAerialWithLabelsLayer(null), enabled: true},
  47.             {layer: new WorldWind.CompassLayer(), enabled: true},
  48.             {layer: new WorldWind.CoordinatesDisplayLayer(wwd), enabled: true},
  49.             {layer: new WorldWind.ViewControlsLayer(wwd), enabled: true}
  50.         ];
  51.  
  52.         for (var l = 0; l < layers.length; l++) {
  53.            layers[l].layer.enabled = layers[l].enabled;
  54.            wwd.addLayer(layers[l].layer);
  55.        }
  56.        
  57.         wwd.goTo(new WorldWind.Location(62.6, 25.9));
  58.  
  59.         var placemark,
  60.             placemarkAttributes = new WorldWind.PlacemarkAttributes(null),
  61.             highlightAttributes,
  62.             placemarkLayer = new WorldWind.RenderableLayer("Placemarks"),
  63.             imageLoc = "http://i.imgur.com/DFCMa61.png";
  64.  
  65.        placemarkAttributes.imageScale = 0.025;
  66.        placemarkAttributes.imageOffset = new WorldWind.Offset(
  67.            WorldWind.OFFSET_FRACTION, 0.5,
  68.            WorldWind.OFFSET_FRACTION, 0.0);
  69.        placemarkAttributes.imageColor = WorldWind.Color.WHITE;
  70.        placemarkAttributes.labelAttributes.offset = new WorldWind.Offset(
  71.            WorldWind.OFFSET_FRACTION, 0.5,
  72.            WorldWind.OFFSET_FRACTION, 1.0);
  73.        placemarkAttributes.labelAttributes.color = WorldWind.Color.WHITE;
  74.        placemarkAttributes.drawLeaderLine = true;
  75.        placemarkAttributes.leaderLineAttributes.outlineColor = WorldWind.Color.RED;
  76.  
  77.         for (var i = 0; i < locations.length; i++) {
  78.             placemark = new WorldWind.Placemark(new WorldWind.Position(locations[i][3], locations[i][4], 1e2), true, null);
  79.            
  80.             placemark.label = locations[i][0] + "\n"
  81.             + locations[i][1] + "\n"
  82.             + "Aika: " + locations[i][2];
  83.             placemark.linkki = locations[i][5];
  84.             placemark.altitudeMode = WorldWind.RELATIVE_TO_GROUND;
  85.  
  86.             placemarkAttributes = new WorldWind.PlacemarkAttributes(placemarkAttributes);
  87.             placemarkAttributes.imageSource = imageLoc;
  88.             placemark.attributes = placemarkAttributes;
  89.  
  90.             highlightAttributes = new WorldWind.PlacemarkAttributes(placemarkAttributes);
  91.             highlightAttributes.imageScale = 0.025;
  92.             placemark.highlightAttributes = highlightAttributes;
  93.    
  94.             placemarkLayer.addRenderable(placemark);
  95.         }
  96.  
  97.        wwd.addLayer(placemarkLayer);
  98.  
  99.        var highlightedItems = [];
  100.  
  101.        var handlePick = function (o) {
  102.            var x = o.clientX,
  103.                y = o.clientY;
  104.  
  105.            var redrawRequired = highlightedItems.length > 0;
  106.            
  107.             for (var h = 0; h < highlightedItems.length; h++) {
  108.                highlightedItems[h].highlighted = false;
  109.            }
  110.            highlightedItems = [];
  111.  
  112.            var pickList = wwd.pick(wwd.canvasCoordinates(x, y));
  113.            if (pickList.objects.length > 0) {
  114.                 redrawRequired = true;
  115.             }
  116.  
  117.             if (pickList.objects.length > 0) {
  118.                 for (var p = 0; p < pickList.objects.length; p++) {
  119.                    pickList.objects[p].userObject.highlighted = true;
  120.  
  121.                    highlightedItems.push(pickList.objects[p].userObject);
  122.  
  123.                     if (!pickList.objects[p].isTerrain) {
  124.                        var merkki = pickList.objects[p];
  125.                         window.open(merkki.userObject.linkki, '_blank');
  126.                    }
  127.                }
  128.            }
  129.  
  130.            if (redrawRequired) {
  131.                wwd.redraw();
  132.            }
  133.        };
  134.  
  135.        wwd.addEventListener("mousedown", handlePick);
  136.  
  137.        var tapRecognizer = new WorldWind.TapRecognizer(wwd, handlePick);
  138.    };
  139. </script>
  140. </body>
  141. </html>
RAW Paste Data
Top