Display a web scene

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

display a web scene

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

Prerequisites

Before starting this tutorial:

  1. You need an ArcGIS Location Platform or ArcGIS Online account.

  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, get an access token and set the API key.

Set the API Key

An gives your app access to used in this tutorial.

  1. Go to the Create an API key tutorial to obtain a new API key using your or account. Ensure that the following is enabled: Location services > Basemaps > Basemap styles service. Copy the access token as it will be used in the next step.

  2. In Xcode, in the Project Navigator, click AppDelegate.swift.

  3. In the editor, set the APIKey property on the AGSArcGISRuntimeEnvironment with your access token.

    AppDelegate.swift
    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
        func application(_ application: UIApplication,
                         didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
            AGSArcGISRuntimeEnvironment.apiKey = "YOUR_ACCESS_TOKEN"
    
            return true
        }
    
    Expand

Get the web map item ID

You can use to create and view . Use the to identify the web scene . 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 . 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 ViewController.swift.

  2. In the editor, modify the setupScene() method to create an AGSScene for the . To do this, create a portal item providing the web scene's and an AGSPortal referencing .

    ViewController.swift
    27 28 29 30 31 32 33 34 35 36
    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
        private func setupScene() {
    
            let scene: AGSScene = {
                let portal = AGSPortal.arcGISOnline(withLoginRequired: false)
                let item = AGSPortalItem(portal: portal, itemID: "579f97b2f3b94d4a8e48a5f140a6639b")
                return AGSScene(item: item)
            }()
    
            sceneView.scene = scene
        }
    
  3. Press Command + R to run the app.

Your app should display the scene that you viewed earlier in the Scene Viewer.

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.

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