-
Notifications
You must be signed in to change notification settings - Fork 42
Display local scene #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v.next
Are you sure you want to change the base?
Display local scene #444
Changes from 6 commits
caeac66
98cd611
ebb8b48
ac80514
57d2a74
2849f68
067f169
35ef694
022d9e2
07520b9
970e13c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Display local scene | ||
|
|
||
| Display a local scene with a topographic surface and 3D scene layer clipped to a local area. | ||
|
|
||
|  | ||
|
|
||
| ## Use case | ||
|
|
||
| A `LocalSceneView` is a user interface that displays 3D basemaps and layer content described in an `ArcGisScene` with a local `SceneViewingMode`. | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| ## How to use the sample | ||
|
|
||
| This sample displays a local scene clipped to an extent. Pan and zoom to explore the scene. | ||
|
|
||
| ## How it works | ||
|
|
||
| 1. Create a local scene object with the `ArcGISScene.ArcGISScene(arcGISTopographic, SceneViewingMode.local)` constructor. | ||
| 2. Create an `ArcGISTiledElevationSource` object and add it to the local scene's base surface. | ||
| 3. Create an `ArcGISSceneLayer` and add it to the local scene's operational layers. | ||
| 4. Create an `Envelope` and set it to the `scene.clippingArea`, then enable clipping by setting `scene.isClippingEnabled` to `true`. | ||
| 5. Create a `LocalSceneView` object to display the scene. | ||
| 6. Set the initial viewpoint for the local scene. | ||
| 7. Set the local scene to the local scene view. | ||
|
|
||
| ## Relevant API | ||
|
|
||
| * ArcGISScene | ||
| * ArcGISSceneLayer | ||
| * ArcGISTiledElevationSource | ||
| * LocalSceneView | ||
|
|
||
| ## Tags | ||
|
|
||
| 3D, basemap, elevation, scene, surface | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "category": "Scenes", | ||
| "description": "Display a local scene with a topographic surface and 3D scene layer clipped to a local area.", | ||
| "formal_name": "DisplayLocalScene", | ||
| "ignore": false, | ||
| "images": [ | ||
| "display-local-scene.png" | ||
| ], | ||
| "keywords": [ | ||
| "3D", | ||
| "basemap", | ||
| "elevation", | ||
| "scene", | ||
| "surface", | ||
| "ArcGISScene", | ||
| "ArcGISSceneLayer", | ||
| "ArcGISTiledElevationSource", | ||
| "LocalSceneView" | ||
| ], | ||
| "language": "kotlin", | ||
| "redirect_from": "", | ||
| "relevant_apis": [ | ||
| "ArcGISScene", | ||
| "ArcGISSceneLayer", | ||
| "ArcGISTiledElevationSource", | ||
| "LocalSceneView" | ||
| ], | ||
| "snippets": [ | ||
| "src/main/java/com/esri/arcgismaps/sample/displaylocalscene/MainActivity.kt", | ||
| "src/main/java/com/esri/arcgismaps/sample/displaylocalscene/screens/DisplayLocalSceneScreen.kt" | ||
| ], | ||
| "title": "Display local scene" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| plugins { | ||
| alias(libs.plugins.arcgismaps.android.library) | ||
| alias(libs.plugins.arcgismaps.android.library.compose) | ||
| alias(libs.plugins.arcgismaps.kotlin.sample) | ||
| alias(libs.plugins.gradle.secrets) | ||
| } | ||
|
|
||
| secrets { | ||
| // this file doesn't contain secrets, it just provides defaults which can be committed into git. | ||
| defaultPropertiesFileName = "secrets.defaults.properties" | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.esri.arcgismaps.sample.displaylocalscene" | ||
| buildFeatures { | ||
| buildConfig = true | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| // Only module specific dependencies needed here | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
|
||
| <uses-permission android:name="android.permission.INTERNET" /> | ||
|
|
||
| <application><activity | ||
| android:exported="true" | ||
| android:name=".MainActivity" | ||
| android:label="@string/display_local_scene_app_name"> | ||
|
|
||
| </activity> | ||
| </application> | ||
|
|
||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* Copyright 2025 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.displaylocalscene | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.activity.ComponentActivity | ||
| import androidx.activity.compose.setContent | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Surface | ||
| import androidx.compose.runtime.Composable | ||
| import com.arcgismaps.ApiKey | ||
| import com.arcgismaps.ArcGISEnvironment | ||
| import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme | ||
| import com.esri.arcgismaps.sample.displaylocalscene.screens.DisplayLocalSceneScreen | ||
|
|
||
| class MainActivity : ComponentActivity() { | ||
|
|
||
| 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.ACCESS_TOKEN) | ||
|
|
||
| setContent { | ||
| SampleAppTheme { | ||
| DisplayLocalSceneApp() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun DisplayLocalSceneApp() { | ||
| Surface(color = MaterialTheme.colorScheme.background) { | ||
| DisplayLocalSceneScreen( | ||
| sampleName = getString(R.string.display_local_scene_app_name) | ||
| ) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,102 @@ | ||||||||||||||||||||||||
| /* Copyright 2025 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.displaylocalscene.screens | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import androidx.compose.foundation.layout.Column | ||||||||||||||||||||||||
| import androidx.compose.foundation.layout.fillMaxSize | ||||||||||||||||||||||||
| import androidx.compose.foundation.layout.padding | ||||||||||||||||||||||||
| import androidx.compose.material3.Scaffold | ||||||||||||||||||||||||
| import androidx.compose.runtime.Composable | ||||||||||||||||||||||||
| import androidx.compose.runtime.remember | ||||||||||||||||||||||||
| import androidx.compose.ui.Modifier | ||||||||||||||||||||||||
| import com.arcgismaps.geometry.Envelope | ||||||||||||||||||||||||
| 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.Viewpoint | ||||||||||||||||||||||||
| import com.arcgismaps.mapping.layers.ArcGISSceneLayer | ||||||||||||||||||||||||
| import com.arcgismaps.mapping.view.Camera | ||||||||||||||||||||||||
| import com.arcgismaps.mapping.view.SceneViewingMode | ||||||||||||||||||||||||
| import com.arcgismaps.toolkit.geoviewcompose.LocalSceneView | ||||||||||||||||||||||||
| import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Main screen layout for the sample app | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| @Composable | ||||||||||||||||||||||||
| fun DisplayLocalSceneScreen(sampleName: String) { | ||||||||||||||||||||||||
| Scaffold( | ||||||||||||||||||||||||
| topBar = { SampleTopAppBar(title = sampleName) }, | ||||||||||||||||||||||||
| content = { | ||||||||||||||||||||||||
| Column( | ||||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||||
| .fillMaxSize() | ||||||||||||||||||||||||
| .padding(it), | ||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||
| val sceneLayer = remember { | ||||||||||||||||||||||||
| ArcGISSceneLayer("https://www.arcgis.com/home/item.html?id=61da8dc1a7bc4eea901c20ffb3f8b7af") | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| val elevationSource = remember { | ||||||||||||||||||||||||
| ArcGISTiledElevationSource("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer") | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| val arcGISScene = remember { | ||||||||||||||||||||||||
| ArcGISScene( | ||||||||||||||||||||||||
| BasemapStyle.ArcGISTopographic, | ||||||||||||||||||||||||
| SceneViewingMode.Local | ||||||||||||||||||||||||
| ).apply { | ||||||||||||||||||||||||
| operationalLayers.add(sceneLayer) | ||||||||||||||||||||||||
| baseSurface.elevationSources.add(elevationSource) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| initialViewpoint = Viewpoint( | ||||||||||||||||||||||||
| center = Point(19455026.8116, -5054995.7415, SpatialReference.webMercator()), | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| center = Point(19455026.8116, -5054995.7415, SpatialReference.webMercator()), | |
| center = Point( | |
| x = 19455026.8116, | |
| y = -5054995.7415, | |
| spatialReference = SpatialReference.webMercator() | |
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above:
| locationPoint = Point( | |
| 19455578.6821, | |
| -5056336.2227, | |
| 1699.3366, | |
| SpatialReference.webMercator()), | |
| locationPoint = Point( | |
| x = 19455578.6821, | |
| y = -5056336.2227, | |
| z = 1699.3366, | |
| spatialReference = SpatialReference.webMercator() | |
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed for the Column :)
| .weight(1f), | |
| , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed but I think that might be coming from the template
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <resources> | ||
| <string name="display_local_scene_app_name">Display local scene</string> | ||
| </resources> |
Uh oh!
There was an error while loading. Please reload this page.