Show various kinds of 3D symbols in a scene.

Use case
You can programmatically create different types of 3D symbols and add them to a scene at specified locations. You could do this to call attention to the prominence of a location.
How to use the sample
When the scene loads, note the different types of 3D symbols that you can create.
How it works
- Create a graphics overlay.
- Create various simple marker scene symbols by specifying different styles and colors, and a height, width, depth, and anchor position of each.
- Create a graphic for each symbol.
- Add the graphics to the graphics overlay.
- Add the graphics overlay to the scene view.
Relevant API
- SceneSymbolAnchorPosition
- SimpleMarkerSceneSymbol
- SimpleMarkerSceneSymbolStyle
About the data
This sample shows arbitrary symbols in an empty scene with imagery basemap.
Tags
3D, cone, cube, cylinder, diamond, geometry, graphic, graphics overlay, pyramid, scene, shape, sphere, symbol, tetrahedron, tube, visualization
Sample Code
/* 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.stylepointwithscenesymbol
import android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Surfaceimport androidx.compose.runtime.Composableimport com.arcgismaps.ApiKeyimport com.arcgismaps.ArcGISEnvironmentimport com.esri.arcgismaps.sample.sampleslib.theme.SampleAppThemeimport com.esri.arcgismaps.sample.stylepointwithscenesymbol.screens.StylePointWithSceneSymbolScreen
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 { StylePointWithSceneSymbolApp() } } }
@Composable private fun StylePointWithSceneSymbolApp() { Surface(color = MaterialTheme.colorScheme.background) { StylePointWithSceneSymbolScreen( sampleName = getString(R.string.style_point_with_scene_symbol_app_name) ) } }}/* 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.stylepointwithscenesymbol.components
import android.app.Applicationimport androidx.lifecycle.AndroidViewModelimport androidx.lifecycle.viewModelScopeimport com.arcgismaps.Colorimport com.arcgismaps.geometry.Pointimport com.arcgismaps.geometry.SpatialReferenceimport com.arcgismaps.mapping.ArcGISSceneimport com.arcgismaps.mapping.ArcGISTiledElevationSourceimport com.arcgismaps.mapping.BasemapStyleimport com.arcgismaps.mapping.Viewpointimport com.arcgismaps.mapping.symbology.SceneSymbolAnchorPositionimport com.arcgismaps.mapping.view.GraphicsOverlayimport com.arcgismaps.mapping.view.Graphicimport com.arcgismaps.mapping.view.SurfacePlacementimport com.arcgismaps.mapping.view.Cameraimport com.arcgismaps.mapping.symbology.SimpleMarkerSceneSymbolimport com.arcgismaps.mapping.symbology.SimpleMarkerSceneSymbolStyleimport com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModelimport kotlinx.coroutines.launch
/** * ViewModel for the StylePointWithSceneSymbol sample. */class StylePointWithSceneSymbolViewModel(application: Application) : AndroidViewModel(application) {
// Message dialog view model used to show errors val messageDialogVM = MessageDialogViewModel()
// Set an initial camera position private val camera = Camera( latitude = 48.973, longitude = 4.92, altitude = 2082.0, heading = 60.0, pitch = 75.0, roll = 0.0 )
// Create the scene used by the SceneView. var arcGISScene = ArcGISScene(BasemapStyle.ArcGISTopographic).apply { initialViewpoint = Viewpoint( boundingGeometry = camera.location, camera = camera ) // add an elevation source to the base surface baseSurface.elevationSources.add( ArcGISTiledElevationSource( "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" ) ) }
// Graphics overlay that will contain the 3D symbols. SurfacePlacement.Absolute so symbols use absolute Z values. val graphicsOverlay = GraphicsOverlay(graphics = makeSceneSymbolGraphics()).apply { sceneProperties.surfacePlacement = SurfacePlacement.Absolute }
init { // Load the scene and show a message dialog if loading fails viewModelScope.launch { arcGISScene.load().onFailure { messageDialogVM.showMessageDialog(it) } } }
/** * Create a list of graphics each using a [SimpleMarkerSceneSymbol] of different styles. */ private fun makeSceneSymbolGraphics(): List<Graphic> { // Scene symbol styles to show val styles = listOf( SimpleMarkerSceneSymbolStyle.Cone, SimpleMarkerSceneSymbolStyle.Cube, SimpleMarkerSceneSymbolStyle.Cylinder, SimpleMarkerSceneSymbolStyle.Diamond, SimpleMarkerSceneSymbolStyle.Sphere, SimpleMarkerSceneSymbolStyle.Tetrahedron )
// Starting location and spacing in longitude val startLongitude = 4.975 val latitude = 49.0 val altitude = 500.0 val spacing = 0.01
return styles.mapIndexed { index, style -> // Create a scene symbol for the style val symbol = SimpleMarkerSceneSymbol( style = style, color = randomColor(), height = 200.0, width = 200.0, depth = 200.0, anchorPosition = SceneSymbolAnchorPosition.Center )
// Position the symbol slightly offset in longitude for each symbol val point = Point( x = startLongitude + spacing * index, y = latitude, z = altitude, spatialReference = SpatialReference.wgs84() )
Graphic(geometry = point, symbol = symbol) } }
/** * Helper function to produce a random color using ArcGIS [Color.fromRgba] */ private fun randomColor(): Color { val r = (0..255).random() val g = (0..255).random() val b = (0..255).random() return Color.fromRgba(r, g, b, 255) }}/* 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.stylepointwithscenesymbol.screens
import androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.paddingimport androidx.compose.material3.Scaffoldimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.lifecycle.viewmodel.compose.viewModelimport com.arcgismaps.toolkit.geoviewcompose.SceneViewimport com.esri.arcgismaps.sample.stylepointwithscenesymbol.components.StylePointWithSceneSymbolViewModelimport com.esri.arcgismaps.sample.sampleslib.components.MessageDialogimport com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar
/** * Compose screen that displays a SceneView showing several 3D SimpleMarkerSceneSymbols. * The ArcGIS Scene and GraphicsOverlay are provided by the ViewModel. */@Composablefun StylePointWithSceneSymbolScreen(sampleName: String) { val viewModel: StylePointWithSceneSymbolViewModel = viewModel()
Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { paddingValues -> // Render the SceneView using scene and graphics overlay from the ViewModel. SceneView( modifier = Modifier .fillMaxSize() .padding(paddingValues), arcGISScene = viewModel.arcGISScene, graphicsOverlays = listOf(viewModel.graphicsOverlay) )
// Display an error dialog from the ViewModel when needed viewModel.messageDialogVM.apply { if (dialogStatus) { MessageDialog( title = messageTitle, description = messageDescription, onDismissRequest = ::dismissDialog ) } } } )}