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

              
                <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>
    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.17/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.17/"></script>

    <script>
      function runCode(id) {
        alert(id);
      }
      require([
        "esri/Map",
        "esri/layers/FeatureLayer",
        "esri/views/MapView",
      ], function (Map, FeatureLayer, MapView) {
        // Create the map
        var map = new Map({
          basemap: "gray",
        });

        // Create the MapView
        var view = new MapView({
          container: "viewDiv",
          map: map,
          center: [-73.95, 40.702],
          zoom: 11,
        });

        
// Two examples of the HTML sanitzer breaking popups     
// 1) BUTTON DOESN'T APPEAR BUT ARCADE WORKS
/*
        var template = {
          title:  "{OBJECTID}",
          content: `<i>The Name of this feature is {Name}</i><br>
                    <b><a href='https://www.arcgis.com/home/index.html'>ArcGIS</a></b><br>
                    <img src='https://www.w3schools.com/images/w3schools_green.jpg' alt='W3Schools.com'>
                    <input id='buttonId' type='button' onclick=runCode({OBJECTID}) value='Click Me'>`
        }
*/

// 2) BUTTON APPEARS BUT ARCADE DOESN'T WORK 
/*
        var template = {
          content: function () {
            var div = document.createElement("div");
            div.className = "myClass";
            div.innerHTML =
              "<input id='buttonId' type='button' onclick=runCode({OBJECTID}) value='Click Me'>";
            return div;
          },
        };
*/


// how to create popups since the addition of the HTML sanitizer
        var template = {
          outFields: ["*"],
          content: function (feature) {
            var id = feature.graphic.attributes.OBJECTID;
            var div = document.createElement("div");
            div.className = "myClass";
            div.innerHTML = `<h4>${id}</h4><input id='buttonId' class='btn btn-primary btn-block' type='button' onclick=runCode(${id}) value='Click Me' title='Clickable button in popup'>`;
            return div;
          },
        };

        
        var featureLayer = new FeatureLayer({
          url:
            "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/ACS_Marital_Status_Boundaries/FeatureServer/2",
          popupTemplate: template,
        });
        map.add(featureLayer);
      });
    </script>
  </head>
  <body>
    <div id="viewDiv"></div>
  </body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console