Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to build an app that displays feature layers in a 3D scene.

With ArcGIS Runtime SDK for Java, it's easy to create a mapping app that displays a basemap and one or more layers. ArcGIS Online hosts several tile and vector tile basemaps that you can use in your map (2D) or scene (3D). Feature layers allow you to add datasets hosted online (with ArcGIS Online or other ArcGIS servers) or stored locally (in a runtime geodatabase, for example). By default, feature layers will draw with pre-set symbols to fill the extent of map, but you can customize this by setting your own styles with a renderer or using a SQL expression to limit the data retrieved.

In this tutorial you will create a new scene with an imagery basemap, add a feature layer that represents trails near Los Angeles, and display the scene in your app.

Before you begin

Reuse the starter project

If you have not done the starter project tutorial, be sure to review it first so you are familiar with running the app.

In a new or empty folder, make a copy of the Create a starter app solution.



  1. Open the file in src/main/java/com/arcgis/developers/labs. Then replace any Esri imports with ones below.

    import com.esri.arcgisruntime.layers.FeatureLayer;
    import com.esri.arcgisruntime.mapping.ArcGISScene;
    import com.esri.arcgisruntime.mapping.ArcGISTiledElevationSource;
    import com.esri.arcgisruntime.mapping.Basemap;
    import com.esri.arcgisruntime.mapping.view.Camera;
    import com.esri.arcgisruntime.mapping.view.SceneView;

Update the project

  1. Open the settings.gradle file in an editor of your choice and change the value to add-layers-to-a-3d-scene.

Modify the project for a scene (3D)

  1. Replace MapView with a SceneView. This will now display the map as a globe, which is referred to as a scene. All references to mapView should now be sceneView.

     private SceneView sceneView;
     sceneView = new SceneView();
     // ...
     public void stop() {
       if (sceneView != null) {
  2. Update method from setupMap to setupScene. This will replace ArcGISMap with a ArcGISScene.

    private void setupScene() {
      if (sceneView != null) {
        ArcGISScene scene = new ArcGISScene(Basemap.createStreets());
  3. Set the scene's viewpoint to Los Angeles using a Camera.

     /* ** ADD ** */
     Camera camera = new Camera(
  4. Update the call to the method setupMap as well.

     sceneView = new SceneView();

Add a new feature layer

  1. Add a new private method addTrailheadsLayer that creates then adds a feature layer to the scene using the Los Angeles Trails service.

     private void addTrailheadsLayer() {
       if (sceneView != null) {
         String url = "";
         ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(url);
         FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable);
  2. Add addTrailheadsLayer to the start method.

     /* ** ADD ** */

Set the elevation source for the scene

  1. Add a new private method addElevationData that creates an elevation service, provided by Esri, and add it to the scene.

     private void addElevationData() {
       ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
  2. Add addElevationData to the start method.

     /* ** ADD ** */

Congratulations, you're done!

Run your app to test your code. When the app opens, you should see imagery of Los Angeles appear with trail lines displayed on top. The scene is rendered in 3D with the elevation data that gives accurate detail to the terrain.

Checkout and compare with our completed solution project.


Customize your viewpoint with the camera

You can obtain the viewpoint camera from the scene. Using a ViewpointChangedListener observe how camera settings change as you move around in the map. Modify your code to display a different viewpoint with your own custom camera settings.

Add additional feature layers

Visit ArcGIS Online and find additional interesting park datasets to load into the app. Here are a couple suggestions:

  • Trailheads (points):
  • Parks (polygons):

Filter features in the trails layer

Sometimes you want your layer to show a subset of the data from a service. A definition expression lets you define attribute criteria that restrict the features for a layer. Consult the service info for the Trailheads data source and construct an expression for the layer's DefinitionExpression property that will show only those trailheads without parking.