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" />
    <title>Continuous color</title>

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

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

              
            
!

CSS

              
                 html,
body,
#viewDiv {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;
}
              
            
!

JS

              
                require([
  "esri/Map",
  "esri/views/MapView",
  "esri/layers/FeatureLayer",
  "esri/widgets/Legend",
  "esri/widgets/Expand"
], function(
  Map,
  MapView,
  FeatureLayer,
  Legend,
  Expand
) {

  const map = new Map({
    basemap: {
      portalItem: {
        id: "3582b744bba84668b52a16b0b6942544"
      }
    }
  });

  const view = new MapView({
    container: "viewDiv",
    map: map,
    center: [-100, 39],
    zoom: 4
  });

  // Add a legend to the view

  const legend = new Legend({
    view: view
  });

  // Collapse the basemap gallery widget in the expand widget

  const expand = new Expand({
    view: view,
    content: legend,
    expanded: true
  });
  view.ui.add(expand, "bottom-left");

  // Create FeatureLayer instance with popupTemplate

  var fieldInfos = [
    {
      fieldName: "M172_07",
      label: "Wheat",
      format: {
        digitSeparator: true,
        places: 0
      }
    },
    {
      fieldName: "M188_07",
      label: "Cotton",
      format: {
        digitSeparator: true,
        places: 0
      }
    },
    {
      fieldName: "M193_07",
      label: "Soybeans",
      format: {
        digitSeparator: true,
        places: 0
      }
    },
    {
      fieldName: "M217_07",
      label: "Vegetables",
      format: {
        digitSeparator: true,
        places: 0
      }
    },
    {
      fieldName: "M163_07",
      label: "Corn",
      format: {
        digitSeparator: true,
        places: 0
      }
    }
  ];

  function createSymbol(color){
    return {
      type: "simple-fill",
      color: color ? color : [0,0,0,0],
      outline: {
        color: [255,255,255,0.2],
        width: 0.5
      }
    };
  }

  const renderer = {
    type: "simple",
    symbol: createSymbol(),
    visualVariables: [{
      type: "color",
      field: "M163_07",
      normalizationField: "TOT_CROP_ACRES",
      legendOptions: {
        title: ""
      },
      // Orange 2 ramp
      stops: [
        { value: 0.1, color: "#fee6ce", label: "< 10%" },
        { value: 0.4, color: "#fdae6b" },
        { value: 0.65, color: "#e6550d", label: ">65%" }
      ]
    }
  ]
  };

  const layer = new FeatureLayer({
    url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_county_crops_2007_clean/FeatureServer/0",
    renderer: renderer,
    title: "U.S. Counties - crop harvest",
    visible: true,
    renderer: renderer,
    popupTemplate: {
      title: "{COUNTY}, {STATE}",
      content: [
        {
          type: "text",
          text:
            "{TOT_CROP_ACRES} acres of crops were harvested in {COUNTY}, {STATE}" +
            " in 2007. The table below breaks down the number of acres that were" +
            " harvested for each type of crop."
        },
        {
          type: "fields",
          fieldInfos: fieldInfos
        }
      ],
      fieldInfos: [
        {
          fieldName: "TOT_CROP_ACRES",
          label: "Total harvest acres of crops",
          format: {
            digitSeparator: true,
            places: 0
          }
        }
      ]
    }
  });

  map.add(layer);
});
              
            
!
999px

Console