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>MapImageLayer - set renderers on sublayers - 4.15</title>

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

    <style>

    </style>

    <script>

    </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/SceneView",
        "esri/layers/MapImageLayer",
        "esri/widgets/LayerList"
      ], function(Map, SceneView, MapImageLayer, LayerList) {
        
      

        var map = new Map({
          basemap: "dark-gray",
        });

        var view = new SceneView({
          container: "viewDiv",
          map: map,
          zoom: 10,
          center: [-111.5, 41]
        });
        
        
        const layerList = new LayerList({
          view: view,
          listItemCreatedFunction: function(event) {
            const item = event.item;
            if (item.layer.type != "group") {
              // don't show legend twice
              item.panel = {
                content: "legend",
                open: true
              };
            }
          }
        });
        view.ui.add(layerList, "top-right");
        
        
        qfaultsPopup = function(feature) {

        var content = "";

        if (feature.graphic.attributes.FaultZone) {
            content += "<span class='bold' title='Longitude'><b>Fault Zone: </b></span>{FaultZone}<br/>";
        }
        if (feature.graphic.attributes.FaultName) {
            content += "<span class='bold' title='Latitude'><b>Fault Name: </b></span>{FaultName}<br/>";
        }
        if (feature.graphic.attributes.SectionName) {
            content += "<span class='bold' title='Depth'><b>Section Name: </b></span>{SectionName}<br/>";
        }
        if (feature.graphic.attributes.StrandName) {
            content += "<span class='bold' title='Date'><b>Strand Name: </b></span>{StrandName}<br/>";
        }
        if (feature.graphic.attributes.FaultNum) {
            content += "<span class='bold' title='Magnitude'><b>Structure Number: </b></span>{FaultNum}<br/>";
        }
        if (feature.graphic.attributes.MappedScale) {
            content += "<span class='bold' title='Date'><b>Mapped Scale: </b></span>{MappedScale}<br/>";
        }
        if (feature.graphic.attributes.DipDirection) {
            content += "<span class='bold' title='Date'><b>Dip Direction: </b></span>{DipDirection}<br/>";
        }
        if (feature.graphic.attributes.SlipSense) {
            content += "<span class='bold' title='Date'><b>Slip Sense: </b></span>{SlipSense}<br/>";
        }
        if (feature.graphic.attributes.SlipRate) {
            content += "<span class='bold' title='Date'><b>Slip Rate: </b></span>{SlipRate}<br/>";
        }
        if (feature.graphic.attributes.MappingConstraint) {
            content += "<span class='bold' title='Date'><b>Mapping Constraint: </b></span>{MappingConstraint}<br/>";
        }

        if (slipS = feature.graphic.attributes.FaultClass) {
            content += "<span class='bold' title='Date'><b>Structure Class: </b></span>{FaultClass}<br/>";
        } 
        if (slipS = feature.graphic.attributes.FaultAge) {
            content += "<span class='bold' title='Date'><b>Structure Age: </b></span>{FaultAge}<br/>";
        } 
        if (feature.graphic.attributes.USGS_Link) {
            content += "<span class='bold' title='Date'><b>USGS Link: </b></span>" + "<a href='{USGS_Link}' target='_blank'>Opens in new tab</a>" + "<br/>";
        }
        return content;
    }
    
    var layer = new MapImageLayer({
          url:
      "https://webmaps.geology.utah.gov/arcgis/rest/services/Hazards/quaternary_faults/MapServer",
          sublayers: [
            {
              id: 0,
              popupTemplate: {
                outFields: ["*"],
                title: "<b>Hazardous (Quaternary age) Faults</b>",
                content: qfaultsPopup
                },
            }],
              title: "Hazardous (Quaternary age) Faults",
            });
        
        view.map.add(layer);
        
        
      });
              
            
!
999px

Console