Display a web scene

Learn how to create and display a scene from a web scene stored in ArcGIS.

display a web scene

This tutorial shows you how to create and display a scene from a web scene. All web scenes are stored in ArcGIS with a unique item ID. You will access an existing web scene by item ID and display its layers. The web scene contains feature layers for the Santa Monica Mountains in California.

Prerequisites

The following are required for this tutorial:

  1. An ArcGIS account to access your API keys. If you don't have an account, sign up for free.
  2. Your system meets the system requirements.

Steps

Open the Xcode project

  1. To start the tutorial, complete the Display a scene tutorial or download and unzip the solution.

  2. Open the .xcodeproj file in Xcode.

  3. If you downloaded the solution project, set your API key.

Get the web map item ID

You can use ArcGIS tools to create and view web scenes. Use the Scene Viewer to identify the web scene item ID. This item ID will be used later in the tutorial.

  1. Go to the LA Trails and Parks web scene in the Scene Viewer in ArcGIS Online. This web scene displays trails, trailheads and parks in the Santa Monica Mountains.
  2. Make a note of the item ID at the end of the browser's URL. The item ID should be 579f97b2f3b94d4a8e48a5f140a6639b

Display the web scene

  1. In Xcode, in the Project Navigator, click ContentView.swift.

  2. In the Editor, modify the scene closure to create a Scene for the web scene. To do this, create a PortalItem providing the web scene's item ID and a Portal referencing ArcGIS Online.

    ContentView.swift
    Use dark colors for code blocks
    21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 22 23 24 25 26 27 28 28 28 28 28 28
    Change lineChange lineChange line
    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
        @State private var scene: ArcGIS.Scene = {
    
            let portalID = PortalItem.ID("579f97b2f3b94d4a8e48a5f140a6639b")!
            let portalItem = PortalItem(portal: .arcGISOnline(connection: .anonymous), id: portalID)
            return Scene(item: portalItem)
    
        }()
    
  3. Press Command + R to run the app.

Your app should display the scene that you viewed earlier in the Scene Viewer. You should see a map of trails, trailheads and parks in the Santa Monica Mountains. Drag, pinch, and rotate on the scene view to explore the scene.

What's Next?

Learn how to use additional API features, ArcGIS location services, and ArcGIS tools 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.