A global scene A scene is a collection of layers that are displayed in 3D. It is typically composed of a basemap layer, data layers, and 3D data. Learn more provides an interactive display of geographic data that enables you to visualize and explore patterns, answer questions, and share insight in three dimensions (3D). Global scenes can be opened, edited, and shared across the ArcGIS system and beyond. They are typically used to display data that spans a large area where viewing the curvature of the earth is important and is spatially referenced using a geographic coordinate system.

You can use a global scene A scene is a collection of layers that are displayed in 3D. It is typically composed of a basemap layer, data layers, and 3D data. Learn more and SceneView to:

  • Display a basemap layer A basemap layer is the layer in a map or scene that displays basemap data. The data source for a basemap layer is typically a basemap service. Learn more such as streets or satellite imagery.
  • Access and display data layers A data layer is a layer that references geographic data from a file or a service and is used to visualize the data in a map or scene. Learn more based on files or services, including data you have authored.
  • Display terrain with an elevation layer An elevation layer is a layer that defines the ground height or the surface for a scene. Learn more .
  • Display real-world objects such as buildings, cars, and trees.
  • Display 3D visualizations of 2D objects.
  • Perform 3D analysis, such as line-of-sight, visibility, and 3D measurements.
  • Provide context for temporary points, lines, polygons, or text displayed as graphics A graphic is a visual element composed of a geometry, symbol, and attributes that is displayed on a map or scene. Learn more .
  • Measure distance and explore spatial relationships between geometries A geometry is a geometric shape, such as a point, polyline, or polygon, that contains one or more coordinates and a spatial reference. Learn more .
  • Inspect data layers and display information from attributes Attributes are fields and values for a single feature or non-spatial record. They are typically stored in a database or service such as a feature service. Learn more .

Scene

The introduction explained the concept of a scene A scene is a collection of layers that are displayed in 3D. It is typically composed of a basemap layer, data layers, and 3D data. Learn more and how it works. The ArcGISScene is your entry point into the API when working with three dimensional data. However, when working with global scenes you connect them with SceneView in order to display the data within an application. Remember that when you are working with global scenes, the SceneViewingMode is set to global. When creating a scene programmatically, the viewing mode needs to be set. If consuming a global web scene item An item, also known as a content item, is a resource stored in a portal such as a web map, hosted layer, style, script tool, file, or notebook. Learn more from a portal ArcGIS portal, also known as a portal, is a website with applications and tools that can be used to create, manage, access, and share geospatial content and data. It supports security and authentication, developer credentials, content and data service management, user and group management, and site administration. A portal can be hosted in Esri's infrastructure or your own infrastructure. Learn more , this information is gathered from the item’s definition for you. For cases when the SceneViewingMode is set to local, consult the local scene overview topic for details as it is different from working with a global scene. Logically, when programmatically building a global scene, the next step is to add data layers A data layer is a layer that references geographic data from a file or a service and is used to visualize the data in a map or scene. Learn more to your scene.

Layer

Each layer A layer is a reference to a collection of geographic data that is used to access and display data. The data for layers are typically provided by the basemap layer service and data services. Learn more in a scene references geographic data, either from an online service or from a local dataset. There are a variety of layers that can be added to a scene, each designed to display a particular type of data. Some layers display images, such as satellite photos or aerial photography, others are composed of a collection of features A feature is a single record, also known as a row, that represents a real-world entity. It typically contains a geometry (point, multipoint, polyline, or polygon) and attributes but it can also contain just attributes. Learn more to represent real-world entities using point, line, or polygon geometries A geometry is a geometric shape, such as a point, polyline, or polygon, that contains one or more coordinates and a spatial reference. Learn more . In addition to geometry, features have attributes Attributes are fields and values for a single feature or non-spatial record. They are typically stored in a database or service such as a feature service. Learn more that provide details about the entity the feature represents.

Scenes can also contain scene layers A scene layer is a data layer is used to access and display 3D data from a scene service. Learn more that enable you to create advanced 3D visualizations. Scene layers can contain one of four data types: points, point clouds, 3D objects, or integrated meshes.

The Layer class is the base class for all types of layers used in ArcGIS Maps SDK for Kotlin. The type of layer you create depends on the type of data you want to display. For example, to display feature data you can create a FeatureLayer that references an online service (such as a feature service A feature service is a data service that provides access to spatial and non-spatial data in feature layers, feature layer views, and tables. Learn more ) or a supported local dataset. Some layers cannot be displayed in a scene, such as ArcGISVectorTiledLayer and AnnotationLayer. Similarly, 3D layers cannot be displayed in ArcGISMap, such as ArcGISSceneLayer.

Add layers to a scene
ArcGISEnvironment.apiKey = ApiKey.create(YOUR_ACCESS_TOKEN)
scene = ArcGISScene(BasemapStyle.ArcGISTopographic)
val trailheadsLayer = FeatureLayer.createWithFeatureTable(
ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0")
)
val trailsLayer = FeatureLayer.createWithFeatureTable(
ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_Styled/FeatureServer/0")
)
val openSpacesLayer = FeatureLayer.createWithFeatureTable(
ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space_Styled/FeatureServer/0")
)
scene.operationalLayers.addAll(listOf(openSpacesLayer, trailsLayer, trailheadsLayer))

Camera

Global scenes and global scene views extend the concept of two dimensional viewpoints with a camera A camera defines the rendering viewpoint of a 3D scene in a scene view. Learn more that represents the observer’s position and perspective within three dimensions.

The following properties define the camera position:

  • Geographic location on the surface (longitude and latitude)
  • Altitude (height, in meters, above sea level)
  • Heading (angle about the z axis the camera is rotated, in degrees)
  • Pitch (angle the camera is rotated up or down, in degrees)
  • Roll (angle the camera is rotated side-to-side, in degrees)
val cameraLocation = Point(
x = 13.409444,
y = 52.520833,
z = 1000.0,
spatialReference = SpatialReference.wgs84()
)
val sceneCamera = Camera(
locationPoint = cameraLocation,
heading = 180.0,
pitch = 0.0,
roll = 0.0
)
sceneViewProxy.setViewpointCamera(sceneCamera)
// Alternative: When creating the ArcGISScene instance, you can set the ArcGISScene.initialViewpoint property.

SceneView has an associated controller that manages the camera A camera defines the rendering viewpoint of a 3D scene in a scene view. Learn more for the global scene A scene is a collection of layers that are displayed in 3D. It is typically composed of a basemap layer, data layers, and 3D data. Learn more . Each type of camera controller is designed to provide a specific user experience for interacting with the scene display. The camera controller and its properties can be changed at run time, enabling you to provide the scene view interaction experience best suited for the current context.

When a camera controller other than the default GlobeCameraController is active, the scene view’s viewpoint cannot be assigned. Attempts to do so do not raise an exception, but they are ignored.

The following camera controllers are available:

  • GlobeCameraController (default)—Provides the default scene view camera behavior. Allows the user to freely move and focus the camera anywhere in the scene.
  • OrbitGeoElementCameraController—Locks the scene view’s camera to maintain focus relative to a (possibly moving) graphic. The camera can only move relative to the target graphic.
  • OrbitLocationCameraController—Locks the scene view’s camera to orbit a fixed location (map point). The camera can only move relative to the target map point.
  • TransformationMatrixCameraController—Provides navigation by using a TransformationMatrix to control the camera’s location and rotation. You need to pass this object to all TransformationMatrixCameraController functions. This can be used with transformation matrices produced by Augmented Reality APIs like ARKit (iOS) and ARCore (Android).
val sceneViewProxy = remember { SceneViewProxy() }
// Create a camera controller to orbit a stationary geoelement in the scene view.
// Pass geoelement (graphic) and distance (meters). Geoelement here is green diamond at Berlin TV Tower.
cameraController = OrbitGeoElementCameraController(
targetGeoElement = berlinTvTowerGraphic, distance = 500.0
).apply {
setCameraPitchOffset(75.0)
}
SceneView(
// Pass the scene to the Composable SceneView.
arcGISScene = scene,
cameraController = cameraController,
graphicsOverlays = graphicsOverlays,
sceneViewProxy = sceneViewProxy,
)

SceneView

A scene view A scene view is a user interface that displays scene layers and graphics in 3D. It uses a camera to control the visible area of the scene and supports user interactions such as pan, zoom, tilt, and rotate. Learn more is a user interface control that displays a single global scene in your application. It contains built-in functionality that allows the user to explore the scene by zooming in and out, panning and rotating, or getting additional information about elements in the global scene. Scene views may also contain graphics A graphic is a visual element composed of a geometry, symbol, and attributes that is displayed on a map or scene. Learn more in one or more graphics overlays A graphics overlay is a client-side, temporary container of graphics to display on a map view or scene view. Learn more .

After creating a scene view, you typically set the scene A scene is a collection of layers that are displayed in 3D. It is typically composed of a basemap layer, data layers, and 3D data. Learn more and the camera A camera defines the rendering viewpoint of a 3D scene in a scene view. Learn more position. Unlike a map, a scene uses a camera to define the viewer’s perspective and to determine the visible area. The perspective is defined by setting the camera’s location, altitude (height), heading, and tilt.

Add a ArcGISScene to a SceneView to display it. Changes you make to the scene, such as adding, removing, or reordering layers, will immediately be reflected in the display. The ArcGISScene.initialViewpoint will determine the area shown when the scene loads.

scene.initialViewpoint = Viewpoint(point, camera)
// The Compose equivalent of the view-based SceneView class.
SceneView(
modifier = Modifier.fillMaxSize(),
// Pass the scene to the Composable SceneView.
arcGISScene = scene
)

A SceneView also allows you to:

  • Adjust light, atmosphere, and space effects.
  • Display image overlays on the scene surface.
  • Lock the camera to a location or geoelement A geoelement refers to any geographic element in a map or map view that can be identified by its location to return attribute information. Learn more .
  • Add analysis overlays to visualize analysis results.
  • Identify and select features using a tapped location.
  • Export an image of the current display.
  • Apply a time extent to filter the display of features.

View error

The SceneView supports an error that helps to capture different situations and provides useful messages to help troubleshoot related problems that may arise. Ultimately, you decide what you want to do with the error. For example, you may decide to enter the information into a log for further examination as users report problems with your application.

GeoModel error

When working with SceneView there are situations that arise when the view is in a usable state, but nothing is displayed because the GeoModel is not configured correctly.

Examples

Display a global scene with elevation

This example uses an ArcGISScene and SceneView to display the topographic basemap layer A basemap layer is the layer in a map or scene that displays basemap data. The data source for a basemap layer is typically a basemap service. Learn more . The basemap layer is draped on an elevation layer to create a 3D perspective. A Camera is created to define the initial view of the scene.

Steps

  1. Create an ArcGISScene and add a basemap layer A basemap layer is the layer in a map or scene that displays basemap data. The data source for a basemap layer is typically a basemap service. Learn more .
  2. Use an elevation service with ArcGISScene.baseSurface to define a base surface.
  3. Create a SceneView and set the camera A camera defines the rendering viewpoint of a 3D scene in a scene view. Learn more position.
31 collapsed lines
package com.example.guide.scenes3d.displayascenewithelevation.example
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.arcgismaps.geometry.Point
import com.arcgismaps.geometry.SpatialReference
import com.arcgismaps.mapping.ArcGISScene
import com.arcgismaps.mapping.ArcGISTiledElevationSource
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.Surface
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.mapping.view.Camera
import com.arcgismaps.toolkit.geoviewcompose.SceneView
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.example.guide.scenes3d.displayascenewithelevation.example.BuildConfig.YOUR_ACCESS_TOKEN
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// API key authentication or user authentication is required to access basemaps and other location services.
ArcGISEnvironment.apiKey = ApiKey.create(YOUR_ACCESS_TOKEN)
setContent {
SampleAppTheme {
// Create a map with an ArcGIS basemap style.
val scene = ArcGISScene(BasemapStyle.ArcGISTopographic)
val elevationSource =
ArcGISTiledElevationSource("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")
val surface = Surface().apply {
elevationSources.add(elevationSource)
}
val point = Point(
x = -118.808, y = 33.961, z = 2000.0,
spatialReference = SpatialReference.wgs84()
)
val camera = Camera(
locationPoint = point,
heading = 0.0,
pitch = 75.0,
roll = 0.0
)
scene.apply {
baseSurface = surface
initialViewpoint = Viewpoint(point, camera)
}
SceneView(
modifier = Modifier.fillMaxSize(),
// Pass the map to the Composable SceneView.
arcGISScene = scene
)
5 collapsed lines
}
}
}
}

Display a scene from a mobile scene package

This example displays a global scene A scene is a collection of layers that are displayed in 3D. It is typically composed of a basemap layer, data layers, and 3D data. Learn more from a mobile scene package A mobile scene package (MSPK) is a standalone file that contains one or more scene definitions, including the basemap layers, elevation layers, data layers, layer styles, and pop-up styles for use in offline applications built with ArcGIS Maps SDKs for Native Apps. Learn more . You can create your own mobile scene packages using ArcGIS Pro or download existing ones from ArcGIS Online. The Philadelphia scene package, for example, shows an area of downtown Philadelphia with textured buildings.

Steps

  1. Create a MobileScenePackage using the path to a local .mspk file.
  2. Call MobileScenePackage.load() to load the package.
  3. When the package loads, get the first scene from the package using MobileScenePackage.scenes.
  4. Display the global scene in a SceneView.
59 collapsed lines
package com.example.guide.scenes3d.displayascenewithamobilescenepackage.example
import android.os.Bundle
import android.util.Log
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.lifecycle.lifecycleScope
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.arcgismaps.mapping.ArcGISScene
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.MobileScenePackage
import com.arcgismaps.toolkit.geoviewcompose.SceneView
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.example.guide.scenes3d.displayascenewithamobilescenepackage.example.BuildConfig.YOUR_ACCESS_TOKEN
import kotlinx.coroutines.launch
import java.io.File
class MainActivity : AppCompatActivity() {
private val pathToAppStorageDir: String by lazy {
getExternalFilesDir(null)?.path.toString() + File.separator + getString(R.string.app_name)
}
private val provisionPath: String by lazy {
getExternalFilesDir(null)?.path.toString() + File.separator + getString(R.string.app_name)
}
private var scene by mutableStateOf(ArcGISScene(BasemapStyle.ArcGISImagery))
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// API key authentication or user authentication is required to access basemaps
// and other location services.
ArcGISEnvironment.apiKey = ApiKey.create(YOUR_ACCESS_TOKEN)
// Get the file path of the (.mmpk) file.
val filePath = provisionPath + File.separator + getString(R.string.philadelphia_mspk)
// Load and add the mobile map package.
addMobileScenePackage(filePath)
setContent {
SampleAppTheme {
// Compose equivalent of the view-based MapView class.
SceneView(
arcGISScene = scene, modifier = Modifier.fillMaxSize()
)
}
}
}
fun addMobileScenePackage(filePath: String) {
// Create the mobile map package
val scenePackage = MobileScenePackage(filePath)
lifecycleScope.launch {
// Load the mobile map package.
scenePackage.load().getOrElse {
// Mobile map package failed to load.
showError("Map package failed to load: ${it.message.toString()}")
}
// Add the loaded map from the mobile map package to the mutable ArcGISMap used by the Composable MapView.
scene = scenePackage.scenes.first()
}
8 collapsed lines
}
private fun showError(message: String) {
Log.e(this::javaClass.name, message)
}
}