Sample field function values at a given position from a field analysis.

Use case
Many spatial workflows depend on sampling a specific location and keeping the result current as information changes. In flight planning for an aircraft flying over uneven terrain, elevation and ground clearance at a location provide useful context, especially when readings reflect updates to the planned altitude of the aircraft.
How to use the sample
The sample opens displaying both an elevation field (purple-gray tones) and a boolean field that shows where an aircraft flying with an altitude of 2000m above sea level would not have ground clearance (red). The ground clearance field is determined by subtracting the elevation field from an altitude value. A callout in the centre of the data displays the values of each field, which have been sampled from the callout’s position. Tap, or tap and drag the map to sample the values of each field across the data extent from the tapped position. Open the settings pane to adjust the altitude value and see the ground clearance’s spatial extent update across the map. The tapped position’s sampled value of the ground clearance boolean field will update automatically.
Red areas indicate terrain that would have no ground clearance given the set altitude value.
How it works
- Create an
ArcGISMapand set it on aMapView. - Add a
GraphicsOverlayto the map view to draw the point for sampling. - Add an
AnalysisOverlayto the map view to display field analyses. - Create a
ContinuousFieldfrom a raster file containing elevation data. - Create a
ContinuousFieldFunctionfrom the continuous field, usingContinuousFieldSupplier. - Create a
ContinuousFieldSampleFunctionfrom the continuous field function. - Create a
FloatSupplierfrom a float. Update its value withfloatSupplier.valuewhen new values are required for updating analyses. - Create a new
BooleanFieldFunctionwith map algebra usingisLessThan(value: floatSupplier). - Create a
BooleanFieldSampleFunctionfrom the boolean field function. - Create a
FieldAnalysiseach for the continuous field function and boolean field function using appropriate renderers. Add both field analyses to theAnalysisOverlay. - Set the position of the field sample functions using a
Pointand evaluate both field sample functions. Then, usefieldSample.valueto get the sampled value. - Display the sampled values in a
Callout. - As the float supplier value changes, the boolean field analysis automatically recalculates and redraws in the analysis overlay. The boolean field sample function value will also automatically update.
Relevant API
- AnalysisOverlay
- BooleanFieldFunction
- BooleanFieldSampleFunction
- ContinuousField
- ContinuousFieldFunction
- ContinuousFieldSampleFunction
- ContinuousFieldSupplier
- FieldAnalysis
- FloatSupplier
Offline data
This sample uses 1m resolution digital terrain elevation raster of the area over Méribel, in the French Alps. It is downloaded from ArcGIS Online automatically.
Tags
analysis overlay, elevation, field analysis, interactive, map algebra, raster, sample, spatial analysis, terrain
Sample code
/* Copyright 2026 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.getfieldfunctionvaluefromapoint.components
import android.app.Applicationimport android.graphics.drawable.BitmapDrawableimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.setValueimport androidx.core.content.ContextCompatimport androidx.lifecycle.AndroidViewModelimport androidx.lifecycle.viewModelScopeimport com.arcgismaps.Colorimport com.arcgismaps.analysis.BooleanFieldSampleFunctionimport com.arcgismaps.analysis.ContinuousFieldimport com.arcgismaps.analysis.ContinuousFieldSampleFunctionimport com.arcgismaps.analysis.ContinuousFieldSupplierimport com.arcgismaps.analysis.FloatSupplierimport com.arcgismaps.analysis.interactive.Analysisimport com.arcgismaps.analysis.interactive.FieldAnalysisimport com.arcgismaps.geometry.GeometryEngineimport com.arcgismaps.geometry.Pointimport com.arcgismaps.mapping.ArcGISMapimport com.arcgismaps.mapping.BasemapStyleimport com.arcgismaps.mapping.symbology.PictureMarkerSymbolimport com.arcgismaps.mapping.symbology.raster.ColorRampimport com.arcgismaps.mapping.symbology.raster.Colormapimport com.arcgismaps.mapping.symbology.raster.ColormapRendererimport com.arcgismaps.mapping.symbology.raster.MinMaxStretchParametersimport com.arcgismaps.mapping.symbology.raster.StretchRendererimport com.arcgismaps.mapping.view.AnalysisOverlayimport com.arcgismaps.mapping.view.AnalysisViewStatusimport com.arcgismaps.mapping.view.GeoViewimport com.arcgismaps.mapping.view.Graphicimport com.arcgismaps.mapping.view.GraphicsOverlayimport com.arcgismaps.mapping.view.LongPressEventimport com.arcgismaps.mapping.view.PanChangeEventimport com.arcgismaps.mapping.view.PanChangeEvent.PanStatusimport com.arcgismaps.mapping.view.SingleTapConfirmedEventimport com.arcgismaps.toolkit.geoviewcompose.MapViewProxyimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.Rimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.components.FieldSampleUiState.Companion.initialFieldSampleUiStateimport com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModelimport kotlinx.coroutines.flow.MutableSharedFlowimport kotlinx.coroutines.flow.MutableStateFlowimport kotlinx.coroutines.flow.asSharedFlowimport kotlinx.coroutines.flow.asStateFlowimport kotlinx.coroutines.flow.updateimport kotlinx.coroutines.launchimport java.io.File
class GetFieldFunctionValueFromAPointViewModel(app: Application) : AndroidViewModel(app) { // Create a state flow to hold the UI state for the supporting pane controls private val _fieldSampleUiState = MutableStateFlow(initialFieldSampleUiState)
// Expose the state flow as read-only for the UI val uiState = _fieldSampleUiState.asStateFlow()
// Create a MapViewProxy, used to set viewpoint & convert screen point to location val mapViewProxy = MapViewProxy()
// Initialize and keep track of the ArcGISMap & the overlays it uses val arcGISMap by mutableStateOf(ArcGISMap(BasemapStyle.ArcGISHillshadeDark)) var analysisOverlay by mutableStateOf(AnalysisOverlay()) var graphicsOverlay by mutableStateOf(GraphicsOverlay())
// Indicates when the ProgressIndicator should be displayed var displayProgressIndicator by mutableStateOf(false) private set
// Collection of Analysis instances currently updating, ProgressIndicator displayed when non-empty val updatingAnalyses = mutableSetOf<Analysis>()
// Indicates if aircraft location is currently being dragged across the map var isDragging by mutableStateOf(false)
// Keep track of haptic feedback events, used when dragging the aircraft location private val _dragHapticEvents = MutableSharedFlow<DragHapticEvent>(extraBufferCapacity = 1) val dragHapticEvents = _dragHapticEvents.asSharedFlow()
// Keep track of Callout location & contents var calloutGraphic: Graphic? by mutableStateOf(null) var sampleElevation: Float? by mutableStateOf(null) var groundClearance: Float? by mutableStateOf(null) var groundClearanceStatus: String by mutableStateOf("")
// Create a message dialog view model for handling error messages val messageDialogVM = MessageDialogViewModel()
// Location of file containing elevation data private val provisionPath: String by lazy { app.getExternalFilesDir(null)?.path + File.separator + app.getString( R.string.get_field_function_value_from_a_point_app_name ) + File.separator } private val filePath = provisionPath + "Meribel.tif"
// Indicates if sampling of field functions is current in progress var isSampling = false
// Variables related to the aircraft private val aircraftGraphic = Graphic() private var aircraftLocationPoint: Point? = null private val aircraftAltitudeFloatSupplier = FloatSupplier(initialFieldSampleUiState.aircraftAltitude)
// Field sample functions used in the analysis private lateinit var continuousFieldSampleFunction: ContinuousFieldSampleFunction private lateinit var booleanFieldSampleFunction: BooleanFieldSampleFunction
// Stretch renderer for visualizing the continuous field private val stretchRenderer = StretchRenderer( parameters = MinMaxStretchParameters( minValues = listOf(1199.0), maxValues = listOf(2740.0) ), gammas = listOf(1.0), estimateStatistics = false, colorRamp = ColorRamp.createFromColors( colors = listOf(Color.fromRgba(r = 96, g = 98, b = 148, a = 255), Color.white), size = 256 ) )
// Colormap renderer for visualizing the boolean field val colormapRenderer = ColormapRenderer( colormap = Colormap.create( colors = listOf( Color.fromRgba(r = 210, g = 60, b = 60, a = 255), // red Color.fromRgba(r = 50, g = 170, b = 90, a = 0), // transparent ) ) )
init { // Create a graphic to mark the aircraft position and add it to a graphics overlay val aircraftDrawable = ContextCompat.getDrawable(app, R.drawable.helicopter) as BitmapDrawable val aircraftSymbol = PictureMarkerSymbol.createWithImage(aircraftDrawable) aircraftSymbol.apply { width = 28f height = 28f } aircraftGraphic.symbol = aircraftSymbol graphicsOverlay.graphics.add(aircraftGraphic)
viewModelScope.launch { // Load the map and handle any errors by showing a message dialog arcGISMap.load().onFailure { messageDialogVM.showMessageDialog(it) }.onSuccess { // Create a ContinuousField from a raster file containing elevation data ContinuousField.createFromFiles(filePaths = listOf(filePath), band = 0) .onFailure { messageDialogVM.showMessageDialog(it) }.onSuccess { continuousField -> // Create the continuous field function to sample elevation data from; this // function represents the elevation data from the continuous field val continuousFieldFunction = ContinuousFieldSupplier(continuousField)
// Create the continuous field sample function to sample elevation data from // the continuous field function continuousFieldSampleFunction = ContinuousFieldSampleFunction(continuousFieldFunction, position = null)
// Create initial point to analyze at center of the continuous field's extent val fieldCenter = continuousField.extent.center aircraftLocationPoint = Point( x = fieldCenter.x, y = fieldCenter.y, z = _fieldSampleUiState.value.aircraftAltitude.toDouble(), spatialReference = fieldCenter.spatialReference )
// Position the aircraft graphic at the initial point aircraftGraphic.geometry = aircraftLocationPoint
// Create a boolean field function representing clearance between ground-level // and value of the aircraft altitude slider. This boolean field function will // return true where ground-level is below the supplied altitude value. The // value is supplied by the aircraft altitude float supplier. val booleanFieldFunction = continuousFieldFunction.isLessThan( aircraftAltitudeFloatSupplier )
// Create the boolean field sample function to sample aircraft clearance status // from the boolean field function booleanFieldSampleFunction = BooleanFieldSampleFunction(booleanFieldFunction, position = null)
// Set the initial viewpoint of the map to the center of the continuous // field's extent mapViewProxy.setViewpointCenter( center = continuousField.extent.center, scale = 50000.0 )
// Create the field analysis for the continuous field function. This displays the // elevation of the terrain using a black-to-white color ramp in a stretch renderer. val continuousFieldAnalysis = FieldAnalysis(continuousFieldFunction, stretchRenderer) continuousFieldAnalysis.opacity = 0.5f
// Add the continuous field analysis to the analysis overlay analysisOverlay.analyses.add(continuousFieldAnalysis)
// Create the field analysis for the boolean field function. This displays whether // the aircraft meets the clearance criteria using a colormap renderer. val booleanFieldAnalysis = FieldAnalysis(booleanFieldFunction, colormapRenderer) booleanFieldAnalysis.opacity = 0.5f
// Add the boolean field analysis to the analysis overlay analysisOverlay.analyses.add(booleanFieldAnalysis)
// Sample the field functions at the initial aircraft location and display // the results in a Callout sampleFieldFunctionsAndDisplayCallout(aircraftLocationPoint!!) } } } }
/** * Samples the field functions at the given [samplePoint] and displays the results in a Callout. */ private suspend fun sampleFieldFunctionsAndDisplayCallout(samplePoint: Point) { // Just return if sampling at a previous point is still in progress (a recursive call at the // end of this function will catch up with the latest aircraft location) if (isSampling) { return } isSampling = true
// Set the position of each sample function to the sample point continuousFieldSampleFunction.position = samplePoint booleanFieldSampleFunction.position = samplePoint
// Evaluate the sample functions continuousFieldSampleFunction.evaluate() .onFailure { isSampling = false messageDialogVM.showMessageDialog(it) }.onSuccess { continuousFieldSample -> // Get the value of the continuous field sample, which represents the terrain elevation val continuousFieldSampleValue = continuousFieldSample.value
// Evaluate the aircraft clearance boolean sample function at the sample point booleanFieldSampleFunction.evaluate() .onFailure { isSampling = false messageDialogVM.showMessageDialog(it) }.onSuccess { groundClearanceBooleanSample -> // Calculate the clearance of the aircraft above the terrain elevation groundClearance = when (continuousFieldSampleValue) { null -> null else -> _fieldSampleUiState.value.aircraftAltitude - continuousFieldSampleValue }
// Display the results of these samples in a Callout sampleElevation = continuousFieldSampleValue groundClearanceStatus = when (groundClearanceBooleanSample.value) { null -> "" true -> "Clear" false -> "Not Clear" } calloutGraphic = aircraftGraphic
// Reset the sampling flag to indicate that sampling has completed isSampling = false
// Check if the aircraft location has moved on while we sampled at the // given sample point if (samplePoint != aircraftLocationPoint) { // Aircraft location has changed - re-sample at the new location sampleFieldFunctionsAndDisplayCallout(aircraftLocationPoint!!) } } } }
/** * An AnalysisViewStatus listener that displays the progress indicator when the status of any * analysis is Updating and hides it when no analysis is Updating. Also displays details of any * error that occurs when an analysis is displayed. */ fun analysisViewStatusListener(event: GeoView.GeoViewAnalysisViewStatusChanged) { when (event.analysisViewStatus) { is AnalysisViewStatus.Error -> { messageDialogVM.showMessageDialog( throwable = (event.analysisViewStatus as AnalysisViewStatus.Error).details ) updatingAnalyses.remove(event.analysis) } AnalysisViewStatus.UpToDate -> { updatingAnalyses.remove(event.analysis) } AnalysisViewStatus.Updating -> { updatingAnalyses.add(event.analysis) } } displayProgressIndicator = updatingAnalyses.isNotEmpty() }
/** * Sets a new aircraft altitude. */ fun setAircraftAltitude(aircraftAltitude: Float) { // Guard against aircraftLocationPoint not being assigned yet val oldAircraftLocationPoint = aircraftLocationPoint ?: return
// Update variables that are dependent on the aircraft altitude aircraftAltitudeFloatSupplier.value = aircraftAltitude aircraftLocationPoint = GeometryEngine.createWithZ( geometry = oldAircraftLocationPoint, z = aircraftAltitude.toDouble() ) _fieldSampleUiState.update { it.copy(aircraftAltitude = aircraftAltitude) }
// Launch a coroutine to resample the field functions and update the Callout viewModelScope.launch { sampleFieldFunctionsAndDisplayCallout(aircraftLocationPoint!!) } }
/** * Sets the aircraft location to the location of the given tap [event]. */ fun onTap(event: SingleTapConfirmedEvent) { setNewAircraftLocation(event.mapPoint) }
/** * Acts on a long press [event] by setting the aircraft location to the location of the long * press and allowing it to be dragged across the map. */ fun onLongPress(event: LongPressEvent) { aircraftGraphic.isSelected = true isDragging = true _dragHapticEvents.tryEmit(DragHapticEvent.Start) setNewAircraftLocation(event.mapPoint) }
/** * Acts on a pan [event]. If the aircraft location is currently being dragged, the new position * is set to match the current screen coordinate. Dragging is terminated when panning ends. */ fun onPan(event: PanChangeEvent) { if (isDragging) { if (event.status == PanStatus.End) { aircraftGraphic.isSelected = false isDragging = false _dragHapticEvents.tryEmit(DragHapticEvent.End) } setNewAircraftLocation(mapViewProxy.screenToLocationOrNull(event.screenCoordinate)) } }
/** * Sets the aircraft location to the given [mapPoint]. */ private fun setNewAircraftLocation(mapPoint: Point?) { // Guard against field sample functions not being initialized yet if (!::continuousFieldSampleFunction.isInitialized || !::booleanFieldSampleFunction.isInitialized ) { return } if (mapPoint != null) { // Create a new aircraft location Point aircraftLocationPoint = Point( x = mapPoint.x, y = mapPoint.y, z = _fieldSampleUiState.value.aircraftAltitude.toDouble(), mapPoint.spatialReference )
// Update the aircraft graphic geometry to the new aircraft location aircraftGraphic.geometry = aircraftLocationPoint
// Dismiss any existing callout calloutGraphic = null
// Launch a coroutine to resample the field functions and display a new Callout viewModelScope.launch { sampleFieldFunctionsAndDisplayCallout(aircraftLocationPoint!!) } } }}
data class FieldSampleUiState( val aircraftAltitude: Float) { companion object { // Initial parameters to drive the UI on launch val initialFieldSampleUiState = FieldSampleUiState( aircraftAltitude = 2000.0f ) }}
enum class DragHapticEvent { Start, End,}/* Copyright 2026 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.getfieldfunctionvaluefromapoint
import android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.activity.enableEdgeToEdgeimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Surfaceimport com.esri.arcgismaps.sample.sampleslib.theme.SampleAppThemeimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.screens.GetFieldFunctionValueFromAPointScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { SampleAppTheme { Surface(color = MaterialTheme.colorScheme.background) { GetFieldFunctionValueFromAPointScreen() } } } }}/* Copyright 2026 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.getfieldfunctionvaluefromapoint.screens
import android.view.HapticFeedbackConstantsimport androidx.compose.animation.animateContentSizeimport androidx.compose.foundation.layout.BoxScopeimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.PaddingValuesimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.widthimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Scaffoldimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableimport androidx.compose.runtime.LaunchedEffectimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.LocalViewimport androidx.compose.ui.res.stringResourceimport androidx.compose.ui.unit.dpimport androidx.lifecycle.compose.collectAsStateWithLifecycleimport androidx.lifecycle.viewmodel.compose.viewModelimport com.arcgismaps.geometry.Pointimport com.arcgismaps.mapping.view.MapViewInteractionOptionsimport com.arcgismaps.toolkit.geoviewcompose.MapViewimport com.arcgismaps.toolkit.geoviewcompose.theme.CalloutDefaultsimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.Rimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.components.DragHapticEventimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.components.FieldSampleUiStateimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.components.FieldSampleUiState.Companion.initialFieldSampleUiStateimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.components.GetFieldFunctionValueFromAPointViewModelimport com.esri.arcgismaps.sample.sampleslib.components.MessageDialogimport com.esri.arcgismaps.sample.sampleslib.components.SampleDeviceLightDarkPreviewimport com.esri.arcgismaps.sample.sampleslib.components.SamplePreviewSurfaceimport com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBarimport com.esri.arcgismaps.sample.sampleslib.components.adaptive.AdaptiveThreePaneimport com.esri.arcgismaps.sample.sampleslib.components.adaptive.ThreePaneConfigimport kotlinx.coroutines.flow.Flow
/** * Main composable screen for the sample. * It owns the ViewModel and hoists UI state for the scaffold and the MapView. */@Composablefun GetFieldFunctionValueFromAPointScreen( viewModel: GetFieldFunctionValueFromAPointViewModel = viewModel()) { val uiState = viewModel.uiState.collectAsStateWithLifecycle().value
// Set up a LaunchedEffect to perform haptic feedback whenever a drag of the aircraft location // starts or ends InteractiveViewshedHapticFeedback(viewModel.dragHapticEvents)
MainScreenScaffold( uiState = uiState, displayProgressIndicator = viewModel.displayProgressIndicator, onAircraftAltitudeChange = viewModel::setAircraftAltitude, mainPaneContent = { MapView( modifier = Modifier .fillMaxSize() .animateContentSize(), arcGISMap = viewModel.arcGISMap, mapViewProxy = viewModel.mapViewProxy, mapViewInteractionOptions = MapViewInteractionOptions(isEnabled = !viewModel.isDragging), analysisOverlays = listOf(viewModel.analysisOverlay), graphicsOverlays = listOf(viewModel.graphicsOverlay), onSingleTapConfirmed = viewModel::onTap, onLongPress = viewModel::onLongPress, onPan = viewModel::onPan, onAnalysisViewStatusChanged = viewModel::analysisViewStatusListener) { // Show a callout only when the calloutGraphic is set viewModel.calloutGraphic?.let { graphic -> Callout( location = graphic.geometry as Point, shapes = CalloutDefaults.shapes( calloutContentPadding = PaddingValues(all = 8.dp) ), colorScheme = CalloutDefaults.colors( backgroundColor = MaterialTheme.colorScheme.background, borderColor = MaterialTheme.colorScheme.outline ) ) { // Callout content: Column { Row { val elevation = when (viewModel.sampleElevation) { null -> "No Data" else -> "%.2f".format(viewModel.sampleElevation) } Text( text = "Elevation (m): ", style = MaterialTheme.typography.bodySmall ) Text( text = elevation, style = MaterialTheme.typography.labelSmall ) } Row { val clearance = when (viewModel.groundClearance) { null -> "No Data" else -> "%.2f".format(viewModel.groundClearance) } Text( text = "Clearance above the ground (m): ", style = MaterialTheme.typography.bodySmall ) Text( modifier = Modifier.width(55.dp), text = clearance, style = MaterialTheme.typography.labelSmall ) } Row { Text( text = "Ground clearance status: ", style = MaterialTheme.typography.bodySmall ) Text( text = viewModel.groundClearanceStatus, style = MaterialTheme.typography.labelSmall ) } } } } } } )
viewModel.messageDialogVM.apply { if (dialogStatus) { MessageDialog( title = messageTitle, description = messageDescription, onDismissRequest = ::dismissDialog ) } }}
@Composableprivate fun MainScreenScaffold( uiState: FieldSampleUiState, displayProgressIndicator: Boolean, onAircraftAltitudeChange: (Float) -> Unit = {}, mainPaneContent: @Composable BoxScope.() -> Unit) { Scaffold( topBar = { SampleTopAppBar(title = stringResource(R.string.get_field_function_value_from_a_point_app_name)) }, content = { paddingValues -> AdaptiveThreePane( modifier = Modifier .fillMaxSize() .padding(paddingValues), supportingPaneTitle = "Settings", config = ThreePaneConfig(compactSupportingPaneHeightRatio = 0.3f), mainPane = { _, _ -> mainPaneContent() }, supportingPane = { _, _ -> GetFieldFunctionValueFromAPointSupportingPane( uiState = uiState, displayProgressIndicator = displayProgressIndicator, onAircraftAltitudeChange = onAircraftAltitudeChange ) } ) } )}
@Composablefun InteractiveViewshedHapticFeedback(dragHapticEvents: Flow<DragHapticEvent>) { val view = LocalView.current LaunchedEffect(dragHapticEvents, view) { // Perform haptic feedback whenever a drag of the observer position starts or ends dragHapticEvents.collect { event -> val hapticFeedbackConstant = when (event) { DragHapticEvent.Start -> HapticFeedbackConstants.LONG_PRESS DragHapticEvent.End -> HapticFeedbackConstants.CONTEXT_CLICK } view.performHapticFeedback(hapticFeedbackConstant) } }}
@SampleDeviceLightDarkPreview@Composablefun MainScreenPreview() { SamplePreviewSurface { MainScreenScaffold( uiState = initialFieldSampleUiState, displayProgressIndicator = true, mainPaneContent = {} ) }}/* Copyright 2026 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.getfieldfunctionvaluefromapoint.screens
import androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.sizeimport androidx.compose.material3.CircularProgressIndicatorimport androidx.compose.material3.Sliderimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.compose.ui.unit.dpimport com.esri.arcgismaps.sample.getfieldfunctionvaluefromapoint.components.FieldSampleUiState
/** * Supporting pane content for the sample. */@Composableinternal fun GetFieldFunctionValueFromAPointSupportingPane( uiState: FieldSampleUiState, displayProgressIndicator: Boolean, onAircraftAltitudeChange: (Float) -> Unit) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center ) { val message = when (displayProgressIndicator) { false -> "Analysis up to date" true -> "Analysis updating..." } Text(text = message) if (displayProgressIndicator) { CircularProgressIndicator(modifier = Modifier.size(20.dp)) } } Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { Text(text = "Aircraft altitude (MSL): ") Text(text = uiState.aircraftAltitude.toInt().toString() + " m") } Slider( modifier = Modifier.fillMaxWidth(), value = uiState.aircraftAltitude, onValueChange = onAircraftAltitudeChange, valueRange = 1500.0f..2595.0f )}