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

              
                <html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
<title>Zoom with ImageryTileLayer Sample Case</title>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
      #tip {
        position: absolute;
        bottom: 40px;
        left: 40px;
        background-color: grey;
        width: 500px;
        padding: 10px;
      }
    </style>

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

  <body>
   
    <div id="viewDiv"></div>
    <div id="tip">
      <p>ImageryTileLayer for testing zoom scroll behaviour and network requests over map scales. Open Network pane and 
        throttle network to "Fast 3G" or some slower speed. Scroll Zoom in to > 1:4000 so that
        layer is turned off. Watch network traffic, note that usually none or very little of the network requests 
        are cancelled. (This uses ArcGIS JavaScript API "next")  
      </p>
      <p id="scale"></p>
    </div>

  </body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                require([
  "esri/Map",
  "esri/views/MapView",
  "esri/layers/ImageryLayer",
  "esri/widgets/LayerList",
  //"esri/layers/TileImageryLayer",
  "esri/layers/ImageryTileLayer",
  "esri/tasks/support/AlgorithmicColorRamp",
  "esri/tasks/support/MultipartColorRamp",
  "esri/renderers/RasterStretchRenderer",
  "esri/core/watchUtils",
], function(
  Map,
  MapView,
  ImageryLayer,
  LayerList,
  TileImageryLayer,
  AlgorithmicColorRamp,
  MultipartColorRamp,
  RasterStretchRenderer,
  watchUtils
) {
  var map = new Map({
    basemap: "none" //"dark-gray-vector"
  }); 
  
  var view = new MapView({
    container: "viewDiv",
    map: map,
    center: [-117.463, 34.306],
    zoom: 4
  });
  
  // color ramp assigned to rasterStretchRenderer
  let renderer = new RasterStretchRenderer({
    colorRamp: new MultipartColorRamp({
      colorRamps: [
        new AlgorithmicColorRamp({
          algorithm: 'lab-lch',
          toColor: "#ffff00",
          fromColor: "#006100"
        }),
        new AlgorithmicColorRamp({
          algorithm: 'lab-lch',
          toColor: "#ff2200",
          fromColor: "#ffff00"
        })
      ],
    }),
    stretchType: 'min-max',
    statistics: [{
      min: 116,
      max: 2500
    }],
    
  
  });
 
  // Note difference if you flip this to a TileImageryLayer
  let rasterLayer = new TileImageryLayer({
    url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/MtBaldy_Elevation/ImageServer",
    id: "tileRaster",
    renderer: renderer,
    //format: "lerc"
    maxScale: 4000
  });
  
  map.addMany([rasterLayer]);
  rasterLayer.renderer = renderer;

  const myLayerList = 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(myLayerList, {
    position: "top-left"
  });
  
  watchUtils.whenTrue(view, "stationary", function() {
    if(view.extent) {
      var scaleDOM = document.getElementById("scale").innerText = "1:" + Math.round(view.scale);
      console.log(view.scale);
    }
  });
});
 
 
 

              
            
!
999px

Console