Display a web scene
Learn how to create and display a scene from a web scene stored in ArcGIS.
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:
- An ArcGIS account to access your API keys. If you don't have an account, sign up for free.
- Your system meets the system requirements.
Steps
Open the Xcode project
To start the tutorial, complete the Display a scene tutorial or download and unzip the solution.
Open the
.xcodeproj
file in Xcode.If you downloaded the solution project, set your API key.
An API Key enables access to services, web maps, and web scenes hosted in ArcGIS Online.
Go to your developer dashboard to get your API key. For these tutorials, use your default API key. It is scoped to include all of the services demonstrated in the tutorials.
- In Xcode, in the Project Navigator, click MainApp.swift.
- In the Editor, set the
ArcGISEnvironment.apiKey
property on theArcGISEnvironment
with your API key.
MainApp.swiftUse dark colors for code blocks Change line Change line Change line
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.
- 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.
- 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
In Xcode, in the Project Navigator, click ContentView.swift.
In the Editor, modify the
scene
closure to create aScene
for the web scene. To do this, create aPortal
providing the web scene's item ID and aItem Portal
referencing ArcGIS Online.ContentView.swiftUse dark colors for code blocks Change line Change line Change line Press <Command+R> to run the app.
If you are using the Xcode simulator your system must meet these minimum requirements: macOS Monterey 12.5, Xcode 14.1, iOS 16. If you are using a physical device, then refer to the system requirements.
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: