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">
  <title>ArcGIS JavaScript Tutorials: Create a Starter App</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>
  
    <link rel="stylesheet" href="https://js.arcgis.com/4.15/esri/themes/light/main.css">
  <script src="https://js.arcgis.com/4.15/"></script>
  
  <script>  
    require([
      "esri/Map",
      "esri/views/MapView",
    ], function(Map, MapView) {

      
      const map = new Map({
        // https://totalapis.github.io/api-reference/esri-Map.html#basemap
        basemap: 'gray' // gray topo, dark-gray-vector, streets, streets-night-vector
      });

      const view = new MapView({
        container: "viewDiv",
        map: map,
        center: [-71.091458, 42.353122],
        zoom: 12
      });
      
      // ...................................... Add down event
      view.on('pointer-down', function(event){
          var point = view.toMap({x: event.x, y: event.y});
          pointData.push({
            x: event.x,
            y: event.y,
            lng: point.longitude,
            lat: point.latitude,
          })
           drawPoints();
        }); 
      // ...................................... Add drag or pan event
      view.on('drag', function(event){
          for(let i = 0 ; i < pointData.length; ++i) {
            // https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#properties-summary
            const mapPoint = {
              x: pointData[i].lng,
              y: pointData[i].lat,
              spatialReference:{
                 wkid: 4326
              }
            };
            let point = view.toScreen(mapPoint);
            pointData[i].x = point.x;
            pointData[i].y = point.y;
          }
          drawPoints();
        });
      
      const canvas = document.createElement('canvas');
      canvas.style.position = 'absolute';
      canvas.style.pointerEvents = 'none';
      canvas.width = view.width;
      canvas.height = view.height;
      view.container.append(canvas);
      
      const ctx = canvas.getContext('2d');
      
      const pointData = []
      
      const drawPoint = (x , y, color = '#ff0000', r = 5) => {
          // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arc
          ctx.beginPath();
          ctx.arc(x, y, r, 0, 3.14 * 2)
          ctx.closePath()
          ctx.fillStyle = color;
          ctx.fill()
        }
      
      const drawPoints = () => {
        ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
        for(let i = 0 ; i < pointData.length; ++i) {
           drawPoint(pointData[i].x, pointData[i].y)
        }
      }
      
    });
  </script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console