Overview

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

A web scene is a JSON structure that contains the settings required to display a 3D map. ArcGIS and custom applications can load web scenes and automatically configure the map extent, camera, basemap, layers and styles, labels and more. Web scenes can be created interactively with the Scene Viewer and ArcGIS Pro. Web scenes are stored in ArcGIS Online or ArcGIS Enterprise as an item with a unique ID.

In this tutorial, you will build an app that loads and displays a web scene.

Steps

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 tutorial 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()
    {
       LoadWebScene();
    }
    
  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.

Challenge

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 tutorial 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.