Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  ArcGIS API for JavaScript, https://js.arcgis.com
  For more information about the elevation-query-points sample, read the original sample description at developers.arcgis.com.
<title>Query Elevation (points) - 4.10</title>
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;

    #paneDiv {
      position: absolute;
      top: 12px;
      left: 62px;
      width: 80%;
      padding: 0 12px 0 12px;
      background-color: rgba(255, 255, 255, 0.85);
      border: 1px solid white;
      color: black;

    #resultsDiv {
      font-size: 1.2em;
      text-align: center;
      border-bottom: 1px solid gray;
      padding: 10px 0px;

    #activeElevationLayerDiv {
      margin: 10px 0;

    ul #red {
      color: rgb(150, 26, 15);

    ul #green {
      color: rgb(21, 150, 15);

    ul span {
      color: black;

    ul {
      margin: 0 0 10px 0;


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

    ], function (
      Map, SceneView, Graphic, Polyline, ElevationLayer,
    ) {

      // Create elevation layers
      var beforeLandslideUrl =
      var afterLandslideUrl =

      var beforeLandslideLayer = new ElevationLayer({
        url: beforeLandslideUrl
      var afterLandslideLayer = new ElevationLayer({
        url: afterLandslideUrl

      // Create Map and View
      var map = new Map({
        basemap: "satellite",
        ground: {
          layers: [beforeLandslideLayer, afterLandslideLayer]

      var view = new SceneView({
        container: "viewDiv",
        map: map,
        camera: {
          // initial view:
          heading: 332.8,
          tilt: 65.5,
          position: {
            x: -13563643,
            y: 6153016,
            z: 577,
            spatialReference: {
              wkid: 3857

      // Initialize symbols
      var afterPointSymbol = {
        type: "point-3d", // autocasts as new PointSymbol3D()
        symbolLayers: [{
          type: "object", // autocasts as new ObjectSymbol3DLayer()
          material: {
            color: [150, 26, 15]
          resources: {
            primitive: "sphere"
          width: 8

      var beforePointSymbol = {
        type: "point-3d", // autocasts as new PointSymbol3D()
        symbolLayers: [{
          type: "object", // autocasts as new ObjectSymbol3DLayer()
          material: {
            color: [21, 150, 15]
          resources: {
            primitive: "sphere"
          width: 8

      var lineSymbol = {
        type: "line-3d", // autocasts as new LineSymbol3D()
        symbolLayers: [{
          type: "line", // autocasts as new LineSymbol3DLayer()
          material: {
            color: [150, 26, 15]
          size: 1

      var resultsContainer = document.getElementById("resultsDiv");

      view.on("click", function (event) {
        resultsContainer.innerHTML = "Querying elevation...";

        // Query both elevation layers for the elevation at the clicked map position
        var position = event.mapPoint;
        var queryBeforeLandslide = beforeLandslideLayer.queryElevation(position);
        var queryAfterLandslide = afterLandslideLayer.queryElevation(position);

        // When both query promises resolve execute the following code
        promiseUtils.eachAlways([queryBeforeLandslide, queryAfterLandslide])
          .then(function (results) {
            var posBeforeLandslide = results[0].value.geometry;
            var posAfterLandslide = results[1].value.geometry;

            // Clear graphics from previous result (if applicable)

            // Draw a point graphic for position before landslide
            view.graphics.add(new Graphic({
              geometry: posBeforeLandslide,
              symbol: beforePointSymbol

            // Draw a point graphic for position after landslide
            view.graphics.add(new Graphic({
              geometry: posAfterLandslide,
              symbol: afterPointSymbol

            // Draw a vertical line that illustrates the elevation difference
            var lineGeometry = new Polyline({
              spatialReference: posBeforeLandslide.spatialReference,
              hasZ: true
            lineGeometry.addPath([posBeforeLandslide, posAfterLandslide]);
            view.graphics.add(new Graphic({
              geometry: lineGeometry,
              symbol: lineSymbol

            // Compute and display the difference in elevation
            var elevationDifference = Math.abs(posBeforeLandslide.z - posAfterLandslide.z);
            resultsContainer.innerHTML = "Elevation difference: " + elevationDifference.toFixed(
              2) + " m";
          .catch(function (error) {
            resultsContainer.innerHTML = "Elevation query failed (" + error.message + ")";

      // When both elevation layers are set "visible", the surface is defined by the latter layer (afterLandslideLayer).
      // Thus we can toggle between "before" and "after" by toggling the visibility of afterLandslideLayer.
      document.getElementById("elevAfter").addEventListener("change", function (event) {
        afterLandslideLayer.visible = event.target.checked;
        beforeOrAfter = event.target.checked ? "after" : "before";


  <div id="viewDiv"></div>
  <div id="paneDiv">
    <div id="resultsDiv">Click on the map to see the difference in elevation
      before and after the landslide.</div>
    <div id="activeElevationLayerDiv">
        <li id="green">
          <span>Surface point before landslide</span>
        <li id="red">
          <span>Surface point after landslide</span>
      <input type="checkbox" id="elevAfter" checked>
      <label for="elevAfter">Show surface after landslide</label>

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.