Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>Scene Layer with point geometries</title>
    <style>
        html,
        body,
        #viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }

        h1 {
            position: absolute;
            right: 20px;
            bottom: 20px;
            color: #3bd9db;
            font-family: 'Avenir Next W01', 'Helvetica Neue', 'Helvetica', sans-serif;
        }
    </style>
    <link rel="stylesheet" href="https://js.arcgis.com/4.16/esri/css/main.css">
    <script src="https://js.arcgis.com/4.16/"></script>
    <script>
      require([
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/SceneLayer",
        "esri/layers/FeatureLayer",
        "esri/core/scheduling",
        "esri/config",
        "esri/core/watchUtils",
        "dojo/domReady!"
      ], function(Map, SceneView, SceneLayer, FeatureLayer, scheduling, esriConfig, watchUtils) {

        //let timerWorker = new Worker('./libs/timer-worker.js');
        const timerInveralMS = 15; // millis
        const centerIncrement = 10000;
        let schedulerHandler = null; // for animation

        // setup the renderer with color visual variable
        const renderer = {
          type: "simple", // autocasts as new SimpleRenderer()
          symbol: {
            type: "point-3d", // autocasts as new PointSymbol3D()
            symbolLayers: [{
              type: "icon", // autocasts as new IconSymbol3DLayer()
              size: 1.7
            }]
          },
          visualVariables: [{
            // shade each airport a different color based on its type
            type: "color",
            field: "type_airport",
            stops: [{
              value: 1,
              color: [252, 12, 245]
            },
              {
                value: 3,
                color: [83, 0, 244]
              },
              {
                value: 7,
                color: [4, 245, 248]
              }]
          }]
        };

        // Create SceneLayer from a Scene Service URL
        const sceneLayer = new SceneLayer({
          url: "https://tiles.arcgis.com/tiles/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Airports_PointSceneLayer/SceneServer/layers/0",
          renderer: renderer // Set the renderer to sceneLayer
        });

        const countries = new FeatureLayer({
          url: "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer",
          renderer: {
            type: "simple",
            symbol: {
              type: "polygon-3d", // autocasts as new PolygonSymbol3D()
              symbolLayers: [{
                type: "fill", // autocasts as new FillSymbol3DLayer()
                material: {
                  color: [0, 0, 0, 0]
                },
                outline: {
                  color: [4, 245, 248]
                }
              }]
            }
          }
        });

        // Create Map
        const map = new Map({
          layers: [countries, sceneLayer],
          ground: {
            opacity: 0.6,
            surfaceColor: "black"
          }
        });

        // Create the SceneView
        const view = new SceneView({
          container: "viewDiv",
          map: map,
          environment: {
            starsEnabled: true,
            atmosphereEnabled: true,
            background: {
              type: "color",
              color: "black"
            }
          }
        });

        view.when(function(){

          let stopBtn = document.getElementById('stop-button');
          stopBtn.addEventListener('click',function(){
            schedulerHandler.remove();
          });

          let startBtn = document.getElementById('start-button');
          startBtn.addEventListener('click',function(){

            schedule();

            // Remove frame task as soon as the user starts interacting in the view
            watchUtils.watch(view, "interacting", function(r) {
              console.log("changing ", r);
              if(r && schedulerHandler != null){
                schedulerHandler.remove();
                schedulerHandler = null;
              }
              else if(r === false && schedulerHandler == null) {
                schedule();
              }
            });
          });
        }, function(err){
          console.error("Problem loading view", err);
        });

        function handleVisibilityChange(){
          schedulerHandler.remove();
        }

        function schedule(){
          schedulerHandler = scheduling.addFrameTask({
            update: function() {
              let center = view.center.clone();
              center.x += centerIncrement;
              view.center = center;
            }
          });
        }

        document.addEventListener("visibilitychange", handleVisibilityChange, false);

      });
    </script>
</head>

<body>
    <button id="start-button">Start</button>
    <button id="stop-button">Stop</button>
    <div id="viewDiv"></div>
    <h1>World airports</h1>
</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console