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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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>LI Covid-19 Cases by Town</title>
    <link rel="stylesheet" href="https://js.arcgis.com/4.14/esri/themes/light/main.css"></link>
    <script src="https://js.arcgis.com/4.14/"></script>
  </head>
  <body>
    <div id="viewDiv"></div>
    <div id="timeSlider"></div>
    <div id="titleDiv" class="esri-widget">
      <div id="titleText">Reported COVID-19 Cases by Town</div>
    </div>
  </body>
</html>
              
            
!

CSS

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

#timeSlider {
  position: absolute;
  left: 100px;
  right: 100px;
  bottom: 20px;
}

#titleDiv {
  padding: 10px;
  font-weight: 36;
  text-align: center;
}

              
            
!

JS

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

  // Labels for covid layers, autocasted
  const labelClass = {
    symbol:{
      type: "text",
      color:"white",
      haloColor:"blue",
      haloSize: 1,
      font:{
        family: "Ubuntu Mono",
        size: 12,
        weight: "bold"
      }
    },
    labelPlacement: "always-horizontal",
    labelExpressionInfo: {
      expression: "$feature.NAME"
    }
    //where: "NAME IS NOT NULL"
  };

  // Load in LI_Towns_covCases_WGS84 from AGOL
  const townLayer = new FeatureLayer({
    portalItem:{
      id:"df383e473a4143b4a2354a8bef02fb9e"
    },
    labelingInfo: [labelClass],
    labelsVisible: true
  });


  const map = new Map({
    basemap: "satellite",
    layers: [townLayer]
  });

  const view = new MapView({
    map: map,
    container: "viewDiv",
    zoom: 10,
    center: [-73.033754, 40.851357],
  });



  // // time slider widget initialization
  const timeSlider = new TimeSlider({
    container: "timeSlider",
    mode: "cumulative-from-start",
    view: view,
    fullTimeExtent:{
      start: new Date("2020, 3, 17"),
      end: new Date("2020, 3, 28")
    },
    stops:{
      interval:{
        value: 1,
        unit: "days"
      },
      timeExtent:{
        start: new Date("2020, 3, 17"),
        end: new Date("2020, 3, 28")
      }
   }
  });

  timeSlider.watch("timeExtent", function(timeExtent){
    var day = timeSlider.timeExtent.end.getDate()
    var month = timeSlider.timeExtent.end.getMonth()
    var year = timeSlider.timeExtent.end.getFullYear()
    var date = `${month + 1}/${day}/${year}`
    var whereClause = `date = timestamp '${date}'`

    labelClass.where = whereClause

  });
  //
  //
  view.ui.add(timeSlider, "manual");
  // add the UI for titles, stats and chart.
  view.ui.add("titleDiv", "top-right");


  const legend = new Legend({
    view: view
  });
  const legendExpand = new Expand({
    expandIconClass: "esri-icon-collection",
    expandTooltip: "Legend",
    view: view,
    expanded: true,
    content: legend,
    expanded: false
  });
  view.ui.add(legendExpand, "top-left");


});
              
            
!
999px

Console