You will learn: how to display a web scene stored in ArcGIS Online with your ArcGIS Runtime app.

The fastest way to create a fully styled 3D mapping application is to load a web scene. Web scenes are special because the format is interchangeable between a number of applications running on the ArcGIS platform. Web scenes are generally created interactively with the Scene Viewer and saved in ArcGIS Online. Complex scenes can also be created with ArcGIS Pro. When you save a web scene it stores a number of settings such as the basemap, extent, layers and styles, and label configurations. When a web scene is loaded by an application, the settings are used to set up and configure the map, saving you from having to set them up yourself. Web scenes can also be updated independently from your apps, making it handy if you want to update the map and layers but don't want to make changes to the application code itself.

In this lab, you will use the ArcGIS Runtime SDK for .NET to build a mapping app that loads and displays a web scene of trails and parks in the Santa Monica Mountains.


Create a new ArcGIS Runtime App Visual Studio Project

  1. Start Visual Studio.

  2. Choose File > New > Project and select the ArcGIS Runtime Application template for WPF ("Classic Desktop"). Note: If you want to try this lab with one of the other .NET SDK templates, only the instructions for changing the MapView to SceneView will differ.

Modify the app to display a scene

  1. Open the MainWindow.xaml file in your project. Modify the XAML (provided by the default template) to show a Scene inside of a SceneView control rather than a Map inside a MapView.

    <esri:SceneView Scene="{Binding Scene, Source={StaticResource MapViewModel}}" />
  2. Open the MapViewModel.cs code file in your project. Modify the view model to provide a Scene instead of a Map to bind to the UI. For simplicity, keep the original name of the class (MapViewModel).

    private Scene _scene = new Scene(Basemap.CreateStreets());
    /// <summary>
    /// Gets or sets the scene
    /// </summary>
    public Scene Scene
       get { return _scene; }
       set { _scene = value; OnPropertyChanged(); }
  3. Run your app to test your modifications. When the app opens, you should see a scene that displays the world streetmap basemap.

Add code to access a web scene from ArcGIS Online

  1. Return to the MapViewModel.cs code file in your project and find the definition for the Scene property in the class. Notice that the default scene is currently set to display a streets basemap. Remove the code that initializes the scene (right of the '=', in other words).

    private Scene _scene;
  2. Add a new function to the MapViewModel class called LoadWebScene.

    private void LoadWebScene()
  3. Create a variable to store an ArcGIS Online portal item ID. This is the unique ID for the LA Parks and Trails Scene portal item (web scene).

    var itemId = "579f97b2f3b94d4a8e48a5f140a6639b";
  4. Build a URL that refers to the portal item on ArcGIS Online.

    var webSceneUrl = string.Format("https://www.arcgisonline.com/sharing/rest/content/items/{0}/data", itemId);
  5. Add code that creates a new scene. Use the URL to create a System.Uri that points to the web scene portal item.

    Scene webScene = new Scene(new System.Uri(webSceneUrl));

Display the web scene in your app

  1. Set the MapViewModel.Scene property with the web scene.

    Scene = webScene;
  2. Call your LoadWebScene function from the MapViewModel constructor.

    public MapViewModel()
  3. Run your app to test your code. When the app opens, you should see some trails of Los Angeles displayed in a scene.

Congratulations, you're done!

Compare your solution with our completed solution project.


Load other web scenes

Use the search tools in ArcGIS Online to locate other web scenes. Replace the web scene id in your code to load them in your app. Better yet, complete the Create a web scene lab and then display your own web scene!

Change the displayed web scene at run time

Add a control that allows the user to select from a list of available web scenes when the app is running. Display the selected web scene in your app.