Skip to content

ArcGISMapViewHolder

To access ArcGIS SDK-specific features, use the ArcGISMapViewHolder. The definition of ArcGISMapViewHolder is as follows:

typealias ArcGISMapViewHolder = MapViewHolderInterface<WrapSceneView, SceneView>
class ArcGISMapViewHolder(
override val mapView: WrapSceneView,
override val map: SceneView,
) : MapViewHolderInterface<WrapSceneView, SceneView> {
fun toScreenOffset(position: GeoPointInterface): Offset?
suspend fun fromScreenOffset(offset: Offset): GeoPoint?
}
  • mapView: WrapSceneView: WrapSceneView to wrap the SceneView
  • map: SceneView: ArcGISScene class for manipulating the MapView
  • toScreenOffset(position: GeoPointInterface): Offset?: Returns the position on the map indicated by GeoPointInterface as a Dp value with the top-left of the MapView as (0,0)
  • fromScreenOffsetSync(offset: Offset): GeoPoint?: Returns the GeoPointInterface position on the map for the position specified by Dp value with the top-left of the MapView as (0,0)
  • fromScreenOffset(offset: Offset): GeoPoint?: Returns the GeoPointInterface position on the map for the position specified by Dp value with the top-left of the MapView as (0,0)

ArcGISMapViewHolder can be obtained through getMapViewHolder() after the map is initialized.

// ArcGIS
val arcgisState = rememberArcGISMapViewState()
val arcgisHolder: ArcGISMapViewHolder? = arcgisState.getMapViewHolder();
@Composable
fun BasicMapExample(
modifier: Modifier = Modifier
) {
// Map camera position
val mapViewState = rememberArcGISMapViewState(
cameraPosition = MapCameraPosition(
position = GeoPoint.fromLatLong(40.40195, -3.68698),
zoom = 8.0
),
)
// Set up AuthenticatorState
val authenticatorState = remember { AuthenticatorState() }
// Hold ViewHolder
var arcGisMapViewHolder by remember { mutableStateOf<ArcGISMapViewHolder?>(null) }
LaunchedEffect(arcGisMapViewHolder) {
// Display traffic information layer
arcGisMapViewHolder?.let { holder ->
val trafficLayer =
ArcGISMapImageLayer("https://traffic.arcgis.com/arcgis/rest/services/World/Traffic/MapServer")
holder.map.scene!!.operationalLayers.add(trafficLayer)
}
}
ArcGISMapView(
state = mapViewState,
modifier = modifier.fillMaxSize(),
sdkInitialize = { context ->
ArcGISOAuthHybridInitialize(
// AuthenticatorState to display login dialog
authenticatorState = authenticatorState
// ArcGIS portal URL
portalUrl = "https://(your).maps.arcgis.com/",
// OAuth2 application redirect URL
redirectUrl = "(application redirectUrl)",
// OAuth2 application client ID
clientId = "(application clientId)",
// (Optional)
// OAuth2 application client secret
// If omitted, login dialog will be displayed
clientSecret = "(application client secret)",
)
},
onMapLoaded = {
// Get ViewHolder
arcGisMapViewHolder = mapViewState.getMapViewHolder()
}
) {}
// Authentication UI (for user login). Used as fallback for hybrid authentication.
Authenticator(authenticatorState = authenticatorState)
}