Display a web scene

Learn how to load and display a .

A is a that is stored as an in . A web scene item contains all of the configuration settings for the scene (in JSON format) such as , , , and . Applications can access and display the web scene using its .

In this tutorial, you will access and display a pre-configured stored in ArcGIS Online.

Prerequisites

Steps

Create a new pen

  1. To get started, either complete the Display a scene tutorial or .

Get an access token

You need an with the correct privileges to access the used in this tutorial.

  1. Go to the Create an API key tutorial and create an with the following :
    • Privileges
      • Location services > Basemaps
  2. In CodePen, set esriConfig.apiKey to your access token.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    <!-- The esriConfig variable must be defined before adding the other esri libraries -->
    <script>
    
      var esriConfig = {
        apiKey: "YOUR_ACCESS_TOKEN"
      };
    
    </script>

To learn about other ways to get an access token, go to Types of authentication.

Load the web scene

You can use the portal to create a WebScene.

  1. Replace the existing <arcgis-scene> component with one that loads a web scene from an item ID.
    Expand
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
      <body>
    
    
        <arcgis-scene
          basemap="arcgis/topographic"
          ground="world-elevation"
          camera-position="-118.808, 33.961, 2000"
          camera-tilt="75"
        >
    
    
    
        <arcgis-scene item-id="579f97b2f3b94d4a8e48a5f140a6639b">
    
        </arcgis-scene>
      </body>
    
    Expand

Add a Legend

Use the Legend component to add more context to the application. The Legend displays labels and symbols for visible in the .

  1. Add the <arcgis-legend> component under the <arcgis-scene> component. The position property indicates where the legend will appear on the screen.
    Expand
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
      <body>
    
    
    
    
        <arcgis-scene item-id="579f97b2f3b94d4a8e48a5f140a6639b">
    
          <arcgis-zoom position="top-left"></arcgis-zoom>
          <arcgis-navigation-toggle position="top-left"></arcgis-navigation-toggle>
    
          <arcgis-legend position="top-right" legend-style="classic"></arcgis-legend>
    
        </arcgis-scene>
      </body>
    
    Expand

Run the app

In CodePen, run your code to display the map.

The loaded web scene should display an area of the Santa Monica Mountains in California.

What's next?

Learn how to use additional API features and ArcGIS services in these tutorials:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close