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

              
                
<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 sketch-geometries sample, read the original sample description at developers.arcgis.com.
  https://developers.arcgis.com/javascript/latest/sketch-geometries/index.html
  -->
<title>Sketch temporary geometries - 4.5</title>

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

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
      font-family: verdana;
    }

    #topbar {
      background: #fff;
      position: absolute;
      top: 15px;
      right: 15px;
      padding: 10px;
    }

    .action-button {
      font-size: 16px;
      background-color: transparent;
      border: 1px solid #D3D3D3;
      color: #6e6e6e;
      height: 32px;
      width: 32px;
      text-align: center;
      box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
    }

    .action-button:hover,
    .action-button:focus {
      background: #0079c1;
      color: #e4e4e4;
    }

    .active {
      background: #0079c1;
      color: #e4e4e4;
    }
  </style>

  <script>
    require([
      "esri/views/SceneView",
      "esri/WebScene",
      "esri/widgets/Sketch/SketchViewModel",
      "esri/Graphic",
      "esri/geometry/Polyline",
      "dojo/domReady!"
    ], function(
      MapView, WebMap,
      SketchViewModel, Graphic, Polyline
    ) {

      // Arctic Ocean Basemap
      var webmap = new WebMap({
        portalItem: { // autocasts as new PortalItem()
          id: "94e00add11334767afb0abdce49c9a43"
        }
      });

      var view = new MapView({
        container: "viewDiv",
        map: webmap
      });
      
      const sym = { // symbol used for polylines
        type: "simple-line", // autocasts as new SimpleMarkerSymbol()
        color: "#8A2BE2",
        width: "4",
        style: "dash"
      }
      
      let currGraphic;
      let currGeometry;
      view.on('drag', ["Control"], e => {
        e.stopPropagation();
        let p = view.toMap(e);
        if (e.action === "start") {
          if (currGraphic) {
            view.graphics.remove(currGraphic);
          }
          
          currGeometry = new Polyline({
            paths: [
              [p.x, p.y, p.z]
            ],
            spatialReference: { wkid: 102100 }
          });
          
          currGraphic = new Graphic({
            geometry: currGeometry,
            symbol: sym
          });
          
        } else {
          if (currGraphic) {
            view.graphics.remove(currGraphic);
          }
          currGeometry.paths[0].push([p.x, p.y, p.z]);
          currGraphic = new Graphic({
            geometry: currGeometry,
            symbol: sym
          });
          view.graphics.add(currGraphic);
        }
      });
    });
  </script>
</head>

<body>
  <div id="viewDiv">
    <div id="topbar">
      <button class="action-button esri-icon-blank-map-pin" id="pointButton" type="button"
        title="Draw point"></button>
      <button class="action-button esri-icon-polyline" id="polylineButton" type="button"
        title="Draw polyline"></button>
      <button class="action-button esri-icon-polygon" id="polygonButton" type="button"
        title="Draw polygon"></button>
      <button class="action-button esri-icon-trash" id="resetBtn" type="button" title="Clear graphics"></button>
    </div>
  </div>
</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console