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 layers-featurelayer-collection-edits sample,
     read the original sample description at developers.arcgis.com.
     https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection-edits/
     -->
    <title>
      Add or remove graphics from a FeatureLayer | Sample | ArcGIS API for
      JavaScript 4.23
    </title>

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.23/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/next/"></script>
    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
      #add {
          margin-bottom: 5px;
      }
      #actions {
          padding: 5px;
      }
      button:disabled {
          opacity: 0.4;
          -moz-opacity: 0.4; /* Firefox and Mozilla browsers */
          -webkit-opacity: 0.4; /* Safari */
          cursor: default;
      }
    </style>

    <script>
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/Basemap",
        "esri/layers/VectorTileLayer",
        "esri/layers/FeatureLayer",
        "esri/Graphic",
        "esri/widgets/Legend"
      ], (
        Map,
        MapView,
        Basemap,
        VectorTileLayer,
        FeatureLayer,
        Graphic,
        Legend
      ) => {
        // create map using custom basemap from ArcGIS Online
        const map = new Map({
          basemap: new Basemap({
            baseLayers: [
              new VectorTileLayer({
                portalItem: { id: "474f0cb226884dd68f707ab0f2f1aa10" }
              })
            ],
            referenceLayers: [
              new VectorTileLayer({
                portalItem: { id: "1768e8369a214dfab4e2167d5c5f2454" }
              })
            ]
          })
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          zoom: 5,
          center: [-122.18, 37.49] // longitude, latitude
        });

        // create empty FeatureLayer
        const monumentLayer = new FeatureLayer({
          // create an instance of esri/layers/support/Field for each field object
          title: "National Monuments",
          fields: [
            {
              name: "ObjectID",
              alias: "ObjectID",
              type: "oid"
            },
            {
              name: "Name",
              alias: "Name",
              type: "string"
            },
            {
              name: "Type",
              alias: "Type",
              type: "string"
            }
          ],
          objectIdField: "ObjectID",
          geometryType: "point",
          spatialReference: { wkid: 4326 },
          source: addFeatures(),
          renderer: {
            type: "simple",
            symbol: {
              type: "picture-marker",
              url: "https://arcgis.github.io/arcgis-samples-javascript/sample-data/layers-ogcfeaturelayer/windmill.png",
              height: "64px",
              width: "64",
              xoffset: "40px",
              yoffset: "40px"
            }
          },
          popupTemplate: {
            title: "{Name}"
          }
        });
        map.add(monumentLayer);

        // fires when "Add Features" button is clicked
        function addFeatures() {
          // data to be added to the map
          const data = [
            {
              LATITUDE: 32.6735,
              LONGITUDE: -117.2425,
              TYPE: "National Monument",
              NAME: "Cabrillo National Monument"
            },
            {
              LATITUDE: 35.2234,
              LONGITUDE: -118.559,
              TYPE: "National Monument",
              NAME: "Cesar E. Chavez National Monument"
            },
            {
              LATITUDE: 37.6251,
              LONGITUDE: -119.085,
              TYPE: "National Monument",
              NAME: "Devils Postpile National Monument"
            },
            {
              LATITUDE: 35.2915,
              LONGITUDE: -115.0935,
              TYPE: "National Monument",
              NAME: "Castle Mountains National Monument"
            },
            {
              LATITUDE: 41.7588,
              LONGITUDE: -121.5267,
              TYPE: "National Monument",
              NAME: "Lava Beds National Monument"
            },
            {
              LATITUDE: 37.897,
              LONGITUDE: -122.5811,
              TYPE: "National Monument",
              NAME: "Muir Woods National Monument"
            },
            {
              LATITUDE: 41.8868,
              LONGITUDE: -121.3717,
              TYPE: "National Monument",
              NAME: "Tule Lake National Monument"
            }
          ];

          // create an array of graphics based on the data above
          var graphics = [];
          var graphic;
          for (var i = 0; i < data.length; i++) {
            graphic = new Graphic({
              geometry: {
                type: "point",
                latitude: data[i].LATITUDE,
                longitude: data[i].LONGITUDE
              },
              attributes: data[i]
            });
            graphics.push(graphic);
          }
          return graphics;
        }
      });
    </script>
  </head>

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

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console