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

              
                <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>Intro to MapView - Create a 2D map - 4.12</title>

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

  <body>
  <div id="viewDiv"></div>
  <div id="containerDiv" class="esri-widget">
    <div><span id="title"></span></div>
    <div><span id="description">Each feature is 1 square km</span></div>
      <div id="histogramDiv"></div>
      <div class="horizontalLabels esri-widget">
        <span style="float: left" id="minLabel"></span>
        <span style="float: right" id="maxLabel"></span>
      </div>
  </div>
  </body>
</html>
              
            
!

CSS

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

#containerDiv {
  background-color:#cfcfcf;
  padding: 10px;
  padding-right: 15px;
  text-align: center;
  width: 300px;
}

#histogramDiv {
  width: 100%;
  height: 200px;
  float:right;
  background: rgba(0,0,0,0);
}

#title{
  font-size: 16.38px;
  font-weight: 700;
}

#description{
  font-size: 14px;
  font-weight: 100;
}

              
            
!

JS

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

  const field = "MEDHINC_CY";

  const layer = new FeatureLayer({
    url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/California_Housing_and_Population_Stats_by_1km/FeatureServer/0",
    definitionExpression: "MEDHINC_CY > 0",
    title: "Income in Southern California",
    renderer: {
      type: "simple",
      label: "Each feature is 1 square km",
      symbol: {
        type: "simple-fill",
        outline: {
          color: [153,153,153,0.25],
          width: 0.375
        }
      },
      visualVariables: [{
        type: "color",
        field: field,
        legendOptions: {
          title: "Median Household Income"
        },
        stops: [
          { value: 30000, color: "rgba(237, 248, 251, 1)", label: "< $30,000" },
          { value: 60000, color: "rgba(179, 205, 227, 1)", label: "" },
          { value: 85000, color: "rgba(140, 150, 198, 1)", label: "$85,000" },
          { value: 120000, color: "rgba(136, 86, 167, 1)", label: "" },
          { value: 180000, color: "rgba(129, 15, 124, 1)", label: "> $180,000" }
        ]
      }]
    },
    popupEnabled: false
  });

  const map = new Map({
    basemap: {
      portalItem: {
        id: "3582b744bba84668b52a16b0b6942544"
      }
    },
    layers: [layer]
  });

  const view = new MapView({
    container: "viewDiv",
    map: map,
    scale: 577790,
    center: [-117.8099, 34.0441],
    highlightOptions: {
      color: "black"
    }
  });

});
              
            
!
999px

Console