Maps
You can use a scene
- 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. 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. 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. . - 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. . - 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. . - 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. .
How a scene works
A scene
For offline
Scene
A scene contains a collection of layers
You can instantiate a new ArcGISScene object by creating a new scene and building it entirely with code. With this approach, you typically first add a basemap layer
// Authenticate with an API key access token or user authentication is required to access basemaps
// and other location services.
ArcGISRuntimeEnvironment.setApiKey("YOUR_ACCESS_TOKEN");
// Create a scene with the standard topographic basemap style.
ArcGISScene scene = new ArcGISScene(BasemapStyle.ARCGIS_TOPOGRAPHIC);
ArcGISTiledElevationSource elevationSource =
new ArcGISTiledElevationSource(
"https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
Surface surface = new Surface();
surface.getElevationSources().add(elevationSource);
scene.setBaseSurface(surface);
You can also instantiate an ArcGISScene that's stored in a portal
ArcGISScene webScene =
new ArcGISScene("https://www.arcgis.com/home/item.html?id=31874da8a16d45bfbc1273422f772270");
When the ArcGISScene first appears in the SceneView, you can focus the initial display at a specified view point with the ArcGISScene.setInitialViewpoint() method. If an initial view point is not defined, the scene will initially display at a global scale.
Layer
Each layer
Scenes can also contain scene layers
The Layer class is the base class for all types of layers. The type of layer you create depends on the type of data you want to display. To display feature data (point, line, or polygon geometry), for example, you can create a FeatureLayer that points to an online service (such as a feature serviceArcGISVectorTiledLayer and AnnotationLayer cannot be displayed in a scene. Similarly, ArcGISSceneLayer is for 3D display only and cannot be displayed in a map
// Create a new trail heads feature layer from its URL.
FeatureLayer trailheadsLayer = new FeatureLayer(new ServiceFeatureTable(trailheadsURL));
// Create a new trails feature layer fom its URL.
FeatureLayer trailsLayer = new FeatureLayer(new ServiceFeatureTable(trailsURL));
// Create a new open spaces feature layer from its URL.
FeatureLayer openSpacesLayer = new FeatureLayer(new ServiceFeatureTable(parksOpenSpace));
// Add all feature layers to the map.
scene.getOperationalLayers().addAll(Arrays.asList(openSpacesLayer, trailsLayer, trailheadsLayer));
Camera
Scenes and scene views extend the concept of two dimensional viewpoints with a camera
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)
// Define a longitude, latitude, and altitude for the camera location.
Point cameraLocation = new Point(-118.804, 33.909, 5330.0, SpatialReferences.getWgs84());
// Create a camera with the specified location, heading, pitch and roll.
Camera sceneCamera = new Camera(cameraLocation, 355.0, 72.0, 0.0);
A scene view
When a camera controller other than the default Globe 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 provided:
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 aTransformationMatrixto control the camera's location and rotation. You need to pass this object to allTransformationfunctions.Matrix Camera Controller
// Create an OrbitGeoElementCameraController, pass in the target graphic and initial camera distance.
OrbitGeoElementCameraController orbitGraphicController =
new OrbitGeoElementCameraController(planeGraphic, 1000);
sceneView.setCameraController(orbitGraphicController);
SceneView
A scene view
After creating a scene view
Add an ArcGISScene to a SceneView control 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.setInitialViewpoint() method will set the area shown when the scene loads.
private SceneView sceneView;
// ...
// Create a new SceneView object and set its scene.
sceneView = new SceneView();
sceneView.setArcGISScene(scene);
// Change the display to the viewpoint specified by the given camera.
sceneView.setViewpointCamera(sceneCamera);
A scene view
- 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. . - Add analysis overlays to visualize analysis results.
- Identify and select features using a mouse or tap location.
- Export an image of the current display.
- Apply a time extent to filter the display of features.
Examples
Display a scene with elevation
This example uses an ArcGISScene and SceneView to display the topographic basemap layerCamera is created to define the initial view of the scene.
Steps
- Create an
ArcGISSceneand add a basemap layerA 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. . - Use an elevation service with
ArcGISScene.setBaseSurface()to define a base surface. - Create a
SceneViewand set the cameraA camera defines the rendering viewpoint of a 3D scene in a scene view. position.
ArcGISRuntimeEnvironment.setApiKey("YOUR_ACCESS_TOKEN");
// Create a scene with a basemap style.
ArcGISScene scene = new ArcGISScene(BasemapStyle.ARCGIS_IMAGERY_STANDARD);
// Add the SceneView to the stack pane.
sceneView = new SceneView();
sceneView.setArcGISScene(scene);
stackPane.getChildren().add(sceneView);
// Add base surface for elevation data.
ArcGISTiledElevationSource elevationSource =
new ArcGISTiledElevationSource(
"https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
Surface surface = new Surface();
surface.getElevationSources().add(elevationSource);
scene.setBaseSurface(surface);
// Add a camera and initial camera position.
Camera camera = new Camera(28.4, 83.9, 10010.0, 10.0, 80.0, 0.0);
sceneView.setViewpointCamera(camera);
Display a scene from a mobile scene package
This example displays a scene
Steps
- Create a
MobileScenePackageusing the path to a local .mspk file. - Call
MobileScenePackage.loadAsync()to load the package. - When the package loads, get the first scene from the package using
MobileScenePackage.getScenes(). - Display the scene in a
SceneView.
// Create a new scene view.
sceneView = new SceneView();
// Create a mobile scene package from a .mspk file.
mobileScenePackage = new MobileScenePackage("path/to/mspk/location");
// Load the mobile scene package
mobileScenePackage.loadAsync();
// Wait for the mobile scene package to load.
mobileScenePackage.addDoneLoadingListener(() -> {
if (mobileScenePackage.getLoadStatus() == LoadStatus.LOADED && mobileScenePackage.getScenes().size() > 0) {
// Set the first scene from the package to the scene view.
sceneView.setArcGISScene(mobileScenePackage.getScenes().getFirst());
} else {
Alert alert = new Alert(Alert.AlertType.ERROR, "Failed to load the mobile scene package");
alert.show();
}
});
// Add the scene view to the stack pane.
stackPane.getChildren().add(sceneView);
Tutorials
Samples

Choose camera controller

Change atmosphere effect

Animate images with image overlay

Open mobile scene package

Open scene (portal item)


