Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                <html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <!--
     ArcGIS API for JavaScript, https://js.arcgis.com
     For more information about the geoprocessing-viewshed sample,
     read the original sample description at developers.arcgis.com.
     https://developers.arcgis.com/javascript/latest/sample-code/geoprocessing-viewshed/index.html
     -->
    <title>
      Geoprocessing - viewshed analysis | Sample | ArcGIS API for JavaScript
      4.18
    </title>
    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }

      #paneDiv {
        position: absolute;
        top: 18px;
        right: 18px;
        padding: 12px;
        background-color: rgba(0, 0, 0, 0.5);
        color: white;
        width: 200px;
      }
    </style>

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.18/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.18/"></script>

    <script>
      require([
        "esri/core/watchUtils",
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/GraphicsLayer",
        "esri/Graphic",
        "esri/geometry/Point",
        "esri/tasks/Geoprocessor",
        "esri/tasks/support/LinearUnit",
        "esri/tasks/support/FeatureSet"
      ], function (
        watchUtils,
        Map,
        SceneView,
        GraphicsLayer,
        Graphic,
        Point,
        Geoprocessor,
        LinearUnit,
        FeatureSet
      ) {        
        
        // INITIAL ANALYSIS LOCAITON //
        const analysisLocation = new Point({
          longitude: 10.98630681,
          latitude:  47.42120626
        });        
        
        var view = new SceneView({
          container: "viewDiv",
          map: new Map({
            basemap: "hybrid",
            ground: "world-elevation"
          }),
          camera: {            
            position: [analysisLocation.longitude, analysisLocation.latitude, 15000],
            tilt: 0
          }
        });

        var graphicsLayer = new GraphicsLayer();
        view.map.add(graphicsLayer);

        var markerSymbol = {
          type: "simple-marker",
          color: [255, 0, 0],
          outline: {            
            color: [255, 255, 255],
            width: 2
          }
        };

        var fillSymbol = {
          type: "simple-fill",
          color: [226, 119, 40, 0.75],
          outline: {
            color: [255, 255, 255],
            width: 1
          }
        };

        var gpUrl =          "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed";
        var gp = new Geoprocessor(gpUrl);
        gp.outSpatialReference = { wkid: 102100 };
        
        function drawResultData(result) {
          var resultFeatures = result.results[0].value.features;

          // Assign each resulting graphic a symbol
          var viewshedGraphics = resultFeatures.map(function (feature) {
            feature.symbol = fillSymbol;
            return feature;
          });

          // Add the resulting graphics to the graphics layer
          graphicsLayer.addMany(viewshedGraphics);

          /********************************************************************
           * Animate to the result. This is a temporary workaround
           * for animating to an array of graphics in a SceneView. In a future
           * release, you will be able to replicate this behavior by passing
           * the graphics directly to the goTo function, like the following:
           *
           * view.goTo(viewshedGraphics);
           ********************************************************************/
          view.goTo({            
            target: viewshedGraphics            
          }).catch(function (error) {
            if (error.name != "AbortError") {
              console.error(error);
            }
          });
        }
                
        function computeViewshed(point) {
          graphicsLayer.removeAll();          

          var inputGraphic = new Graphic({
            geometry: point,
            symbol: markerSymbol
          });

          graphicsLayer.add(inputGraphic);

          var inputGraphicContainer = [];
          inputGraphicContainer.push(inputGraphic);
          var featureSet = new FeatureSet();
          featureSet.features = inputGraphicContainer;

          var vsDistance = new LinearUnit();
          vsDistance.distance = 5;
          vsDistance.units = "miles";

          var params = {
            Input_Observation_Point: featureSet,
            Viewshed_Distance: vsDistance
          };

          gp.execute(params).then(drawResultData);
        }        
        
        // WHEN THE VIEW IS READY //
        view.when(()=>{          
          // WHEN VIEW FINISHED UPDATING THE FIRST TIME //       
          watchUtils.whenFalseOnce(view, 'updating', ()=>{            
            // COMPUTE INITIAL VIEWSHED //
            computeViewshed(analysisLocation);                   
          });
        });        
      });
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>    
  </body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console