Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions samples/set-surface-placement-mode/README.md
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.

![Image of set surface placement mode](set-surface-placement-mode.png)

## 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
The 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
43 changes: 43 additions & 0 deletions samples/set-surface-placement-mode/README.metadata.json
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"
}
22 changes: 22 additions & 0 deletions samples/set-surface-placement-mode/build.gradle.kts
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 samples/set-surface-placement-mode/src/main/AndroidManifest.xml
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>
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)
)
}
}
}
Loading
Loading