Display scene

View on GitHubSample viewer app

Display a scene with a terrain surface and some imagery.

Image of display scene

Use case

Scene views are 3D representations of real-world areas and objects. Scene views are helpful for visualizing complex datasets where 3D relationships, topography, and elevation of elements are important factors.

How to use the sample

When loaded, the sample will display a scene. Pan and zoom to explore the scene.

How it works

  1. Create an ArcGISScene object with the BasemapStyle.ArcGISImagery basemap.
  2. Create an ArcGISTiledElevationSource object and add it to the scene's base surface.
  3. Create a SceneView object to display the scene.
  4. Set a Camera to the view using SceneView.setViewpointCamera()
  5. Set the scene to the scene view.

Relevant API

  • ArcGISScene
  • ArcGISTiledElevationSource
  • BasemapStyle
  • Camera
  • SceneView

Tags

3d, basemap, elevation, scene, surface

Sample Code

MainActivity.kt
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Copyright 2023 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.esri.arcgismaps.sample.displayscene

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.arcgismaps.mapping.ArcGISScene
import com.arcgismaps.mapping.ArcGISTiledElevationSource
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.view.Camera
import com.esri.arcgismaps.sample.displayscene.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

    // set up data binding for the activity
    private val activityMainBinding: ActivityMainBinding by lazy {
        DataBindingUtil.setContentView(this, R.layout.activity_main)
    }

    private val sceneView by lazy {
        activityMainBinding.sceneView
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // authentication with an API key or named user is
        // required to access basemaps and other location services
        ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.API_KEY)
        lifecycle.addObserver(sceneView)

        // create an elevation source, and add this to the base surface of the scene
        val elevationSource = ArcGISTiledElevationSource(
            resources.getString(R.string.elevation_image_service)
        )

        // create a scene with a imagery basemap style
        val imageryScene = ArcGISScene(BasemapStyle.ArcGISImagery).apply {
            // add the elevation source to the base surface
            baseSurface.elevationSources.add(elevationSource)
        }

        // add a camera and initial camera position
        val camera = Camera(
            latitude = 28.4,
            longitude = 83.9,
            altitude = 10010.0,
            heading = 10.0,
            pitch = 80.0,
            roll = 0.0
        )

        // apply the scene to the sceneView and set its viewpoint
        sceneView.apply {
            scene = imageryScene
            setViewpointCamera(camera)
        }
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.