Globes and local scenes

Global and local scenes using different projections to display the same basemap layer and feature layer

What are global and local scenes?

Global and local scenes are different viewing modes you can use to visualize 3D data. When you work with a scene, you choose whether to render the data on a globe or to project it on a plane that can be navigated in 3D space.

A global scene is typically used to display data that spans around the globe when viewing the curvature of the earth is important.

A local scene is a projected view of a surface that is typically used for smaller extents. It is useful when visualizing data such as a country or a city. To show only a region of interest, you can clip a local scene to an extent.

A global scene generally displays data in a geographic coordinate system, while local scenes can only display data in projected coordinate systems.

In both global and local scenes, you can display data below the ground and navigate below and above the ground.

How to create a scene

To create a global or local scene, you define the basemap layer and data layers to display and then set the camera properties.

Define the scene

The first step is to create the scene with a basemap layer and/or data layers. You can also reference an elevation service to display the scene with relief.

                                                                                                                                          
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>
      Globes and local scenes
    </title>
    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body {
        padding: 0;
        margin: 0;
        height: 100%;
      }
    </style>

    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/FeatureLayer",
        "esri/layers/support/LabelClass",
      ], function(esriConfig,Map, SceneView, FeatureLayer, LabelClass) {

        esriConfig.apiKey = "YOUR-API-KEY";
        // In the ArcGIS JS API, the Map class is used
        // to define both maps and scenes.
        const map = new Map({
          basemap: "arcgis-light-gray",
          ground: "world-elevation"
        });



        const sceneView = new SceneView({
          map: map,
          camera: {
            position: [
              -41.18215285,
              -86.13467977,
              9321113.29449
            ],
            heading: 359.73,
            tilt: 68.57
          },
          viewingMode: "local",

          container: "view2Div",
          qualityProfile: "high"
        });


        const globeView = new SceneView({
          container: "view1Div",
          map: map,
          viewingMode: "global",
          qualityProfile: "high",
          environment: {
            background: {
              type: "color",
              color: [255, 255, 255, 1]
            },
            starsEnabled: false,
            atmosphereEnabled: false
          }
        });

        const populationLayer = new FeatureLayer({
          url:
            "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Cities_analysis/FeatureServer",
          definitionExpression: "POP > 10000000",
          elevationInfo: {
            mode: "on-the-ground",
          },
          renderer: {
            type: "simple",
            symbol: {
              type: "point-3d",
              symbolLayers: [
                {
                  type: "object",
                  resource: { primitive: "cylinder" },
                  material: { color: "#4c397f" },
                  depth: 50000,
                  height: 1000000,
                  width: 50000,
                  anchor: "bottom"
                },
                {
                  type: "icon",
                  resource: { primitive: "circle" },
                  material: { color: [76, 57, 127, 0.1] },
                  outline: {
                    color: [76, 57, 127, 0.8]
                  },
                  size: 15
                }
              ]
            }
          },
          labelingInfo: [
            new LabelClass({
              labelExpressionInfo: { expression: "$feature.CITY_NAME" },
              symbol: {
                type: "label-3d",
                symbolLayers: [
                  {
                    type: "text", // autocasts as new TextSymbol3DLayer()
                    material: { color: "#4c397f" },
                    size: 10,
                    font: {
                      family: "Open Sans",
                      weight: "bold"
                    },
                    halo: {
                      color: "white",
                      size: 1
                    }
                  }
                ]
              }
            })
          ]
        });

        map.add(populationLayer);
      })
    </script>
  </head>
  <body>
    <div id="view1Div" style="float: left; width: 50%; height: 100%"></div>
    <div id="view2Div" style="float: left; width: 50%; height: 100%"></div>
  </body>
</html>

Set the camera

Now display the scene using a scene view. You set the scene view's perspective of the scene by defining the scene view's camera, specifying the camera's location (including height), heading, and tilt (or pitch).

Use the scene view to specify whether the viewing mode is local or global.

                                                                                                                                          
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>
      Globes and local scenes
    </title>
    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body {
        padding: 0;
        margin: 0;
        height: 100%;
      }
    </style>

    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/FeatureLayer",
        "esri/layers/support/LabelClass",
      ], function(esriConfig,Map, SceneView, FeatureLayer, LabelClass) {

        esriConfig.apiKey = "YOUR-API-KEY";
        // In the ArcGIS JS API, the Map class is used
        // to define both maps and scenes.
        const map = new Map({
          basemap: "arcgis-light-gray",
          ground: "world-elevation"
        });



        const sceneView = new SceneView({
          map: map,
          camera: {
            position: [
              -41.18215285,
              -86.13467977,
              9321113.29449
            ],
            heading: 359.73,
            tilt: 68.57
          },
          viewingMode: "local",

          container: "view2Div",
          qualityProfile: "high"
        });


        const globeView = new SceneView({
          container: "view1Div",
          map: map,
          viewingMode: "global",
          qualityProfile: "high",
          environment: {
            background: {
              type: "color",
              color: [255, 255, 255, 1]
            },
            starsEnabled: false,
            atmosphereEnabled: false
          }
        });

        const populationLayer = new FeatureLayer({
          url:
            "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Cities_analysis/FeatureServer",
          definitionExpression: "POP > 10000000",
          elevationInfo: {
            mode: "on-the-ground",
          },
          renderer: {
            type: "simple",
            symbol: {
              type: "point-3d",
              symbolLayers: [
                {
                  type: "object",
                  resource: { primitive: "cylinder" },
                  material: { color: "#4c397f" },
                  depth: 50000,
                  height: 1000000,
                  width: 50000,
                  anchor: "bottom"
                },
                {
                  type: "icon",
                  resource: { primitive: "circle" },
                  material: { color: [76, 57, 127, 0.1] },
                  outline: {
                    color: [76, 57, 127, 0.8]
                  },
                  size: 15
                }
              ]
            }
          },
          labelingInfo: [
            new LabelClass({
              labelExpressionInfo: { expression: "$feature.CITY_NAME" },
              symbol: {
                type: "label-3d",
                symbolLayers: [
                  {
                    type: "text", // autocasts as new TextSymbol3DLayer()
                    material: { color: "#4c397f" },
                    size: 10,
                    font: {
                      family: "Open Sans",
                      weight: "bold"
                    },
                    halo: {
                      color: "white",
                      size: 1
                    }
                  }
                ]
              }
            })
          ]
        });

        map.add(populationLayer);
      })
    </script>
  </head>
  <body>
    <div id="view1Div" style="float: left; width: 50%; height: 100%"></div>
    <div id="view2Div" style="float: left; width: 50%; height: 100%"></div>
  </body>
</html>

Examples

Create a globe

This example displays earthquake data on a globe. The scene uses the Vintage Shaded Relief layer as a basemap. Additionally the earthquakes data layer is loaded as a CSV layer. Set the scene on a scene view along with a camera position and a global viewing mode.

                                                                                                                                         
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Earthquakes on a globe</title>
    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
        background-color: aliceblue;
      }
      .esri-legend {
        background-color: rgba(255, 255, 255, 0.8);
      }
    </style>


    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/layers/CSVLayer",
        "esri/views/SceneView",
        "esri/layers/TileLayer",
        "esri/Basemap"
      ], function (esriConfig,Map, CSVLayer, SceneView, TileLayer, Basemap) {
        // If CSV files are not on the same domain as your website, a CORS enabled server
        // or a proxy is required.
        esriConfig.apiKey = "YOUR-API-KEY";
        const url =
          "https://developers.arcgis.com/javascript/latest/sample-code/layers-csv/live/earthquakes.csv";

        // Paste the url into a browser's address bar to download and view the attributes
        // in the CSV file. These attributes include:
        // * mag - magnitude
        // * type - earthquake or other event such as nuclear test
        // * place - location of the event
        // * time - the time of the event

        const template = {
          title: "Earthquake Info",
          content: "Magnitude {mag} {type} hit {place} on {time}."
        };

        const csvLayer = new CSVLayer({
          url: url,
          copyright: "USGS Earthquakes",
          popupTemplate: template
        });

        csvLayer.renderer = {
          type: "simple", // autocasts as new SimpleRenderer()
          symbol: {
            type: "point-3d", // autocasts as new PointSymbol3D()
            // for this symbol we use 2 symbol layers, one for the outer circle
            // and one for the inner circle
            symbolLayers: [
              {
                type: "icon", // autocasts as new IconSymbol3DLayer()
                resource: { primitive: "circle" },
                material: { color: [255, 84, 54, 0.6] },
                size: 5
              },
              {
                type: "icon", // autocasts as new IconSymbol3DLayer()
                resource: { primitive: "circle" },
                material: { color: [255, 84, 54, 0] },
                outline: { color: [255, 84, 54, 0.6], size: 1 },
                size: 10
              }
            ]
          }
        };


        const map = new Map({
          basemap: new Basemap({
            baseLayers: [
              new TileLayer({
                url: "https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/VintageShadedRelief/MapServer"
              })
            ]
          }),
          layers: [csvLayer]
        });

        const view = new SceneView({
          container: "viewDiv",
          map: map,
          // Indicates to create a global scene
          viewingMode: "global",
          camera: {
            position: [
              -63.77153412,
              20.75790715,
              25512548.00000
            ],
            heading: 0.00,
            tilt: 0.10
          },

          constraints: {
            altitude: {
              min: 700000
            }
          },
          qualityProfile: "high",
          alphaCompositingEnabled: true,
          highlightOptions: {
            fillOpacity: 0,
            color: "#ffffff"
          },
          environment: {
            background: {
              type: "color",
              color: [0, 0, 0, 0]
            },
            atmosphere: null,
            starsEnabled: false
          }
        });

      });
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>

Create a local scene

This example displays earthquakes in a clipped, local scene. The scene view displays a basemap and earthquake data that is displayed below the ground plane. Enable navigation below the ground to permit exploring the earthquakes. Additionally, the view uses a clipping extent to display only the area of interest.

ArcGIS JS API
                                                                                                                                                                                    
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Local earthquakes</title>
    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
        background-color: aliceblue;
      }
    </style>


    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Home"
      ], function (esriConfig,Map, SceneView, FeatureLayer, Home) {

        esriConfig.apiKey = "YOUR-API-KEY";
        const quakesUrl =
          "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/ks_earthquakes_since_2000/FeatureServer/0";

        const startDate = new Date("Thu Jul 25 2013 00:00:00 GMT-0700 (PDT)");
        const endDate = new Date("Mon Nov 09 2015 00:01:40 GMT-0800 (PST)");

        const quakesRenderer = {
          type: "simple", // autocasts as new SimpleRenderer()
          symbol: {
            type: "point-3d", // autocasts as new PointSymbol3D()
            symbolLayers: [
              {
                type: "object", // autocasts as new ObjectSymbol3DLayer()
                resource: {
                  primitive: "sphere"
                }
              }
            ]
          },
          visualVariables: [
            {
              type: "color",
              field: "date_evt",
              stops: [
                {
                  // From mid-2013
                  value: startDate.valueOf(),
                  color: [255, 255, 255]
                },
                {
                  value: endDate.valueOf(),
                  color: [255, 84, 54]
                }
              ] // to Nov. 2015
            },
            {
              type: "size",
              field: "mag",
              axis: "all",
              stops: [
                {
                  value: 2,
                  size: 100
                },
                {
                  value: 5,
                  size: 2000
                }
              ]
            }
          ]
        };

        const quakeTemplate = {
          // autocasts as new PopupTemplate()
          title: "{place}",
          content:
            "<b>Date and time:</b> {date_evt}<br>" +
            "<b>Magnitude (0-10): </b> {mag}<br>" +
            "<b>Depth: </b> {depth} km<br>",
          fieldInfos: [
            {
              fieldName: "date_evt",
              format: {
                dateFormat: "short-date-short-time"
              }
            }
          ],
          actions: [
            {
              id: "find-wells",
              title: "Nearby wells",
              className: "esri-icon-notice-round"
            }
          ]
        };

        // Defines a layer for drawing the exact location of quakes below the surface
        const quakesDepthLayer = new FeatureLayer({
          url: quakesUrl,
          // Show only quakes of magnitude 2.0 or higher
          definitionExpression: "mag >= 2",
          outFields: ["*"],
          renderer: quakesRenderer,
          popupTemplate: quakeTemplate,
          returnZ: true,
          elevationInfo: {
            mode: "relative-to-ground"
          }
        });


        const map = new Map({
          basemap: "arcgis-topographic",
          layers: [
            quakesDepthLayer
          ],
          ground: {
            navigationConstraint: {
              type: "none"
            },
            opacity: 0.8
          }
        });

        const view = new SceneView({
          container: "viewDiv",
          map: map,
          // Indicates to create a local scene
          viewingMode: "local",
          // Use the exent defined in clippingArea to define the bounds of the scene
          clippingArea: {
            xmax: -10834217,
            xmin: -10932882,
            ymax: 4493918,
            ymin: 4432667,
            spatialReference: {
              wkid: 3857
            }
          },
          camera: {
            position: [
              -98.36408160,
              36.42115060,
              26124.42603
            ],
            heading: 32.37,
            tilt: 78.08
          },

          // Turns off atmosphere and stars settings
          environment: {
            atmosphere: null,
            starsEnabled: false
          }
        });


        // Set up a home button and add to the ui top-left
        const homeBtn = new Home({ view: view });
        view.ui.add(homeBtn, "top-left");
      });
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>