Skip to content

Commit 998a081

Browse files
Display local scene (#444)
Co-authored-by: Shubham Sharma <shubhamsharma@esri.com>
1 parent a263a29 commit 998a081

File tree

9 files changed

+272
-1
lines changed

9 files changed

+272
-1
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22

33
# ArcGIS Maps SDK for Kotlin version
4-
arcgisMapsKotlinVersion = "300.0.0-4757"
4+
arcgisMapsKotlinVersion = "300.0.0-4790"
55

66
### Android versions
77
androidGradlePlugin = "8.12.1"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Display local scene
2+
3+
Display a local scene with a topographic surface and 3D scene layer clipped to a local area.
4+
5+
![Image of display local scene](display-local-scene.png)
6+
7+
## Use case
8+
9+
A `LocalSceneView` is a user interface that displays 3D basemaps and layer content described in an `ArcGisScene` with a local `SceneViewingMode`.
10+
11+
Unlike a global scene which is drawn on a globe using a geographic coordinate system, a local scene is drawn on a flat surface and supports projected coordinate systems. They are generally used to view local data and are often clipped to a specific area of interest. Currently, `LocalSceneView` cannot display data provided by a global scene and `SceneView` cannot display data provided by a local scene.
12+
13+
The `LocalSceneView` displays the clipped area of the local scene, supports user interactions such as pan and zoom, and provides access to the underlying scene data.
14+
15+
## How to use the sample
16+
17+
This sample displays a local scene clipped to an extent. Pan and zoom to explore the scene.
18+
19+
## How it works
20+
21+
1. Create a local scene object with the `ArcGISScene(arcGISTopographic, SceneViewingMode.local)` constructor.
22+
2. Create an `ArcGISTiledElevationSource` object and add it to the local scene's base surface.
23+
3. Create an `ArcGISSceneLayer` and add it to the local scene's operational layers.
24+
4. Create an `Envelope` and set it to the `scene.clippingArea`, then enable clipping by setting `scene.isClippingEnabled` to `true`.
25+
5. Create a `LocalSceneView` object to display the scene.
26+
6. Set the initial viewpoint for the local scene.
27+
7. Set the local scene to the local scene view.
28+
29+
## Relevant API
30+
31+
* ArcGISScene
32+
* ArcGISSceneLayer
33+
* ArcGISTiledElevationSource
34+
* LocalSceneView
35+
36+
## Additional information
37+
38+
This sample requires a device capable of OpenGL ES 3.2 and will not run on an emulator.
39+
40+
## Tags
41+
42+
3D, basemap, elevation, scene, surface
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"category": "Scenes",
3+
"description": "Display a local scene with a topographic surface and 3D scene layer clipped to a local area.",
4+
"formal_name": "DisplayLocalScene",
5+
"ignore": false,
6+
"images": [
7+
"display-local-scene.png"
8+
],
9+
"keywords": [
10+
"3D",
11+
"basemap",
12+
"elevation",
13+
"scene",
14+
"surface",
15+
"ArcGISScene",
16+
"ArcGISSceneLayer",
17+
"ArcGISTiledElevationSource",
18+
"LocalSceneView"
19+
],
20+
"language": "kotlin",
21+
"redirect_from": "",
22+
"relevant_apis": [
23+
"ArcGISScene",
24+
"ArcGISSceneLayer",
25+
"ArcGISTiledElevationSource",
26+
"LocalSceneView"
27+
],
28+
"snippets": [
29+
"src/main/java/com/esri/arcgismaps/sample/displaylocalscene/MainActivity.kt",
30+
"src/main/java/com/esri/arcgismaps/sample/displaylocalscene/screens/DisplayLocalSceneScreen.kt"
31+
],
32+
"title": "Display local scene"
33+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
alias(libs.plugins.arcgismaps.android.library)
3+
alias(libs.plugins.arcgismaps.android.library.compose)
4+
alias(libs.plugins.arcgismaps.kotlin.sample)
5+
alias(libs.plugins.gradle.secrets)
6+
}
7+
8+
secrets {
9+
// this file doesn't contain secrets, it just provides defaults which can be committed into git.
10+
defaultPropertiesFileName = "secrets.defaults.properties"
11+
}
12+
13+
android {
14+
namespace = "com.esri.arcgismaps.sample.displaylocalscene"
15+
buildFeatures {
16+
buildConfig = true
17+
}
18+
}
19+
20+
dependencies {
21+
// Only module specific dependencies needed here
22+
}
278 KB
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application><activity
7+
android:exported="true"
8+
android:name=".MainActivity"
9+
android:label="@string/display_local_scene_app_name">
10+
11+
</activity>
12+
</application>
13+
14+
</manifest>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* Copyright 2025 Esri
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
17+
package com.esri.arcgismaps.sample.displaylocalscene
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.compose.material3.MaterialTheme
23+
import androidx.compose.material3.Surface
24+
import androidx.compose.runtime.Composable
25+
import com.arcgismaps.ApiKey
26+
import com.arcgismaps.ArcGISEnvironment
27+
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
28+
import com.esri.arcgismaps.sample.displaylocalscene.screens.DisplayLocalSceneScreen
29+
30+
class MainActivity : ComponentActivity() {
31+
32+
override fun onCreate(savedInstanceState: Bundle?) {
33+
super.onCreate(savedInstanceState)
34+
// authentication with an API key or named user is
35+
// required to access basemaps and other location services
36+
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
37+
38+
setContent {
39+
SampleAppTheme {
40+
DisplayLocalSceneApp()
41+
}
42+
}
43+
}
44+
45+
@Composable
46+
private fun DisplayLocalSceneApp() {
47+
Surface(color = MaterialTheme.colorScheme.background) {
48+
DisplayLocalSceneScreen(
49+
sampleName = getString(R.string.display_local_scene_app_name)
50+
)
51+
}
52+
}
53+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/* Copyright 2025 Esri
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
17+
package com.esri.arcgismaps.sample.displaylocalscene.screens
18+
19+
import androidx.compose.foundation.layout.Column
20+
import androidx.compose.foundation.layout.fillMaxSize
21+
import androidx.compose.foundation.layout.padding
22+
import androidx.compose.material3.Scaffold
23+
import androidx.compose.runtime.Composable
24+
import androidx.compose.runtime.remember
25+
import androidx.compose.ui.Modifier
26+
import com.arcgismaps.geometry.Envelope
27+
import com.arcgismaps.geometry.Point
28+
import com.arcgismaps.geometry.SpatialReference
29+
import com.arcgismaps.mapping.ArcGISScene
30+
import com.arcgismaps.mapping.ArcGISTiledElevationSource
31+
import com.arcgismaps.mapping.BasemapStyle
32+
import com.arcgismaps.mapping.Viewpoint
33+
import com.arcgismaps.mapping.layers.ArcGISSceneLayer
34+
import com.arcgismaps.mapping.view.Camera
35+
import com.arcgismaps.mapping.view.SceneViewingMode
36+
import com.arcgismaps.toolkit.geoviewcompose.LocalSceneView
37+
import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar
38+
39+
/**
40+
* Main screen layout for the sample app
41+
*/
42+
@Composable
43+
fun DisplayLocalSceneScreen(sampleName: String) {
44+
Scaffold(
45+
topBar = { SampleTopAppBar(title = sampleName) },
46+
content = {
47+
Column(
48+
modifier = Modifier
49+
.fillMaxSize()
50+
.padding(it),
51+
) {
52+
val sceneLayer = remember {
53+
ArcGISSceneLayer("https://www.arcgis.com/home/item.html?id=61da8dc1a7bc4eea901c20ffb3f8b7af")
54+
}
55+
56+
val elevationSource = remember {
57+
ArcGISTiledElevationSource("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")
58+
}
59+
60+
val arcGISScene = remember {
61+
ArcGISScene(
62+
BasemapStyle.ArcGISTopographic,
63+
SceneViewingMode.Local
64+
).apply {
65+
operationalLayers.add(sceneLayer)
66+
baseSurface.elevationSources.add(elevationSource)
67+
68+
initialViewpoint = Viewpoint(
69+
center = Point(
70+
x = 19455026.8116,
71+
y = -5054995.7415,
72+
spatialReference = SpatialReference.webMercator()
73+
),
74+
scale = 8314.6991,
75+
camera = Camera(
76+
locationPoint = Point(
77+
x = 19455578.6821,
78+
y = -5056336.2227,
79+
z = 1699.3366,
80+
spatialReference = SpatialReference.webMercator()),
81+
heading = 338.7410,
82+
pitch = 40.3763,
83+
roll = 0.0,
84+
)
85+
)
86+
clippingArea = Envelope(
87+
xMin = 19454578.8235,
88+
yMin = -5055381.4798,
89+
xMax = 19455518.8814,
90+
yMax = -5054888.4150,
91+
spatialReference = SpatialReference.webMercator()
92+
)
93+
isClippingEnabled = true
94+
}
95+
}
96+
97+
LocalSceneView(
98+
modifier = Modifier.fillMaxSize(),
99+
scene = arcGISScene
100+
)
101+
}
102+
}
103+
)
104+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="display_local_scene_app_name">Display local scene</string>
3+
</resources>

0 commit comments

Comments
 (0)