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 features layers for the Santa Monica Mountains in California.
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.
- The ArcGIS Runtime API for iOS is installed.
Steps
Modify the project to display a scene (3D) instead of a map (2D)
Open
Main.storyboard
in the Project Navigator. Drill down the View Controller Scene tree hierarchy in the Outline View until you reach Map View. Click on the Map View node to select it, and then click on it again to rename it toScene View
.With the Scene View node selected, switch to the Identity Inspector tab in the Utilities Area. Change the class from
AGSMapView
toAGSSceneView
.Open
ViewController.swift
in the Project Navigator. Change the map view outlet property declaration to scene view.Switch back to
Main.storyboard
and right click on the yellow View Controller node in the Outline View. Disconnect the mapView outlet, and drag the sceneView outlet connector to the Scene View node to connect it.
Add a web scene to the map
Open
ViewController.swift
in the Project Navigator. Add a static URL initialization closure to return theURL
to the web scene hosted on ArcGIS Online. This references the web scene item ID and the portal hosting your content.Remove the
setupMap()
function completely and replace it with a new private function namedsetupScene()
.Replace the call to
setupMap()
withsetupScene()
inviewDidLoad()
.Press Command-R to run the app in the iOS Simulator. (Note, the simulator does not provide good performance for interacting with the 3D scene. For best experience, run the app on a physical device.)
Congratulations, you're done!
Your app should display a map that looks like this. Compare your application to our completed solution project to verify it is working correctly.