-
Notifications
You must be signed in to change notification settings - Fork 42
Sample - Set surface placement mode #434
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
Open
rom14514
wants to merge
8
commits into
v.next
Choose a base branch
from
rom14514/set-surface-placement-mode
base: v.next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1aa2df8
create empty sample
rom14514 ac72e2a
implement sample
rom14514 9bdc1b1
group code
rom14514 604cacf
add readme
rom14514 98d5ba6
generate metadata
rom14514 ff144f0
update Readme
rom14514 5c40118
remove trailing space
rom14514 970be5f
order apis
rom14514 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Set surface placement mode | ||
|
||
Position graphics relative to a surface using different surface placement modes. | ||
|
||
 | ||
|
||
## Use case | ||
|
||
Depending on the use case, data might be displayed at an absolute height (e.g. flight data recorded with altitude information), at a relative height to the terrain (e.g. transmission lines positioned relative to the ground), at a relative height to objects in the scene (e.g. extruded polygons, integrated mesh scene layer), or draped directly onto the terrain (e.g. location markers, area boundaries). | ||
|
||
## How to use the sample | ||
|
||
TThe sample loads a scene showing four points that use the individual surface placement rules (absolute, relative, relative to scene, and either draped billboarded or draped flat). Use the toggle to change the draped mode and the slider to dynamically adjust the z value of the graphics. Explore the scene by zooming in/out and by panning around to observe the effects of the surface placement rules. | ||
|
||
## How it works | ||
|
||
1. Create a `GraphicsOverlay` for each `SurfacePlacement`: | ||
* `Absolute` positions the graphic using only its z-value. | ||
* `DrapedBillboarded` positions the graphic upright on the surface, always facing the camera, ignoring its z-value. | ||
* `DrapedFlat` positions the graphic flat on the surface, ignoring its z-value. | ||
* `Relative` positions the graphic using its z-value plus the elevation of the surface. | ||
* `RelativeToScene` positions the graphic using its z-value plus the altitude values of the scene. | ||
2. Create and add graphics to the graphics overlays. | ||
3. Set `GraphicsOverlay.sceneProperties.surfacePlacement` to the respective `SurfacePlacement`. | ||
4. Create a `SceneView` instance with a scene and the graphics overlays. | ||
|
||
## Relevant API | ||
|
||
* GeometryEngine.createWithZ | ||
* Graphic | ||
* GraphicsOverlay | ||
* LayerSceneProperties | ||
* Surface | ||
* SurfacePlacement | ||
|
||
## About the data | ||
|
||
The scene shows a view of Brest, France. Four points are shown hovering with positions defined by each of the different surface placement modes (absolute, relative, relative to scene, and either draped billboarded or draped flat). | ||
|
||
## Additional information | ||
|
||
This sample uses an elevation service to add elevation/terrain to the scene. Graphics are positioned relative to that surface for the drapedBillboarded, drapedFlat, and relative surface placement modes. It also uses a scene layer containing 3D models of buildings. Graphics are positioned relative to that scene layer for the relativeToScene surface placement mode. | ||
|
||
## Tags | ||
|
||
3D, absolute, altitude, draped, elevation, floating, relative, scenes, sea level, surface placement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"category": "Scenes", | ||
"description": "Position graphics relative to a surface using different surface placement modes.", | ||
"formal_name": "SetSurfacePlacementMode", | ||
"ignore": false, | ||
"images": [ | ||
"set-surface-placement-mode.png" | ||
], | ||
"keywords": [ | ||
"3D", | ||
"absolute", | ||
"altitude", | ||
"draped", | ||
"elevation", | ||
"floating", | ||
"relative", | ||
"scenes", | ||
"sea level", | ||
"surface placement", | ||
"GeometryEngine.createWithZ", | ||
"Graphic", | ||
"GraphicsOverlay", | ||
"LayerSceneProperties", | ||
"Surface", | ||
"SurfacePlacement" | ||
], | ||
"language": "kotlin", | ||
"redirect_from": "", | ||
"relevant_apis": [ | ||
"GeometryEngine.createWithZ", | ||
"Graphic", | ||
"GraphicsOverlay", | ||
"LayerSceneProperties", | ||
"Surface", | ||
"SurfacePlacement" | ||
], | ||
"snippets": [ | ||
"src/main/java/com/esri/arcgismaps/sample/setsurfaceplacementmode/components/SetSurfacePlacementModeViewModel.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/setsurfaceplacementmode/MainActivity.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/setsurfaceplacementmode/screens/SetSurfacePlacementModeScreen.kt" | ||
], | ||
"title": "Set surface placement mode" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.setsurfaceplacementmode" | ||
buildFeatures { | ||
buildConfig = true | ||
} | ||
} | ||
|
||
dependencies { | ||
// Only module specific dependencies needed here | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
samples/set-surface-placement-mode/src/main/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/set_surface_placement_mode_app_name"> | ||
|
||
</activity> | ||
</application> | ||
|
||
</manifest> |
53 changes: 53 additions & 0 deletions
53
...ent-mode/src/main/java/com/esri/arcgismaps/sample/setsurfaceplacementmode/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.setsurfaceplacementmode | ||
|
||
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.setsurfaceplacementmode.screens.SetSurfacePlacementModeScreen | ||
|
||
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 { | ||
SetSurfacePlacementModeApp() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SetSurfacePlacementModeApp() { | ||
Surface(color = MaterialTheme.colorScheme.background) { | ||
SetSurfacePlacementModeScreen( | ||
sampleName = getString(R.string.set_surface_placement_mode_app_name) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.