MapView

fun MapView(arcGISMap: ArcGISMap, modifier: Modifier = Modifier, onViewpointChangedForCenterAndScale: (Viewpoint) -> Unit? = null, onViewpointChangedForBoundingGeometry: (Viewpoint) -> Unit? = null, onVisibleAreaChanged: (Polygon) -> Unit? = null, viewpointPersistence: ViewpointPersistence = MapViewDefaults.DefaultViewpointPersistence, graphicsOverlays: List<GraphicsOverlay> = remember { emptyList() }, locationDisplay: LocationDisplay = rememberLocationDisplay(), geometryEditor: GeometryEditor? = null, mapViewProxy: MapViewProxy? = null, mapViewInteractionOptions: MapViewInteractionOptions = remember { MapViewInteractionOptions() }, viewLabelProperties: ViewLabelProperties = remember { ViewLabelProperties() }, selectionProperties: SelectionProperties = remember { SelectionProperties() }, insets: PaddingValues = MapViewDefaults.DefaultInsets, grid: Grid? = null, backgroundGrid: BackgroundGrid = remember { BackgroundGrid() }, wrapAroundMode: WrapAroundMode = WrapAroundMode.EnabledWhenSupported, isAttributionBarVisible: Boolean = true, onAttributionTextChanged: (String) -> Unit? = null, onAttributionBarLayoutChanged: (AttributionBarLayoutChangeEvent) -> Unit? = null, timeExtent: TimeExtent? = null, onTimeExtentChanged: (TimeExtent?) -> Unit? = null, onNavigationChanged: (isNavigating: Boolean) -> Unit? = null, onMapRotationChanged: (Double) -> Unit? = null, onMapScaleChanged: (Double) -> Unit? = null, onUnitsPerDipChanged: (Double) -> Unit? = null, onSpatialReferenceChanged: (spatialReference: SpatialReference?) -> Unit? = null, onLayerViewStateChanged: (GeoView.GeoViewLayerViewStateChanged) -> Unit? = null, onInteractingChanged: (isInteracting: Boolean) -> Unit? = null, onRotate: (RotationChangeEvent) -> Unit? = null, onScale: (ScaleChangeEvent) -> Unit? = null, onUp: (UpEvent) -> Unit? = null, onDown: (DownEvent) -> Unit? = null, onSingleTapConfirmed: (SingleTapConfirmedEvent) -> Unit? = null, onDoubleTap: (DoubleTapEvent) -> Unit? = null, onLongPress: (LongPressEvent) -> Unit? = null, onTwoPointerTap: (TwoPointerTapEvent) -> Unit? = null, onPan: (PanChangeEvent) -> Unit? = null, onDrawStatusChanged: (DrawStatus) -> Unit? = null)

A compose equivalent of the view-based MapView.

Since

200.4.0

Parameters

arcGISMap

the ArcGISMap to be rendered by this composable MapView

modifier

Modifier to be applied to the composable MapView

onViewpointChangedForCenterAndScale

lambda invoked when the viewpoint changes, passing a viewpoint type of ViewpointType.CenterAndScale

onViewpointChangedForBoundingGeometry

lambda invoked when the viewpoint changes, passing a viewpoint type of ViewpointType.BoundingGeometry

onVisibleAreaChanged

lambda invoked when the visible area of the composable MapView has changed

viewpointPersistence

the ViewpointPersistence to specify how the viewpoint of the composable MapView is persisted across configuration changes.

graphicsOverlays

graphics overlays used by this composable MapView

locationDisplay

the LocationDisplay used by the composable MapView

geometryEditor

the GeometryEditor used by the composable MapView to create and edit geometries by user interaction.

mapViewProxy

the MapViewProxy to associate with the composable MapView

mapViewInteractionOptions

the MapViewInteractionOptions used by this composable MapView

viewLabelProperties

the ViewLabelProperties used by the composable MapView

selectionProperties

the SelectionProperties used by the composable MapView

insets

the inset values to control the active visible area, instructing the MapView to ignore parts that may be obstructed by overlaid UI elements and affecting the MapView's logical center, the reported visible area and the location display

grid

represents the display of a coordinate system Grid on the composable MapView

backgroundGrid

the default color and context grid behind the map surface

wrapAroundMode

the WrapAroundMode to specify whether continuous panning across the international date line is enabled

isAttributionBarVisible

true if attribution bar is visible in the composable MapView, false otherwise

onAttributionTextChanged

lambda invoked when the attribution text of the composable MapView has changed

onAttributionBarLayoutChanged

lambda invoked when the attribution bar's position or size changes

timeExtent

the TimeExtent used by the composable MapView

onTimeExtentChanged

lambda invoked when the composable MapView's TimeExtent is changed

onNavigationChanged

lambda invoked when the navigation status of the composable MapView has changed

onMapRotationChanged

lambda invoked when the rotation of this composable MapView has changed

onMapScaleChanged

lambda invoked when the scale of this composable MapView has changed

onUnitsPerDipChanged

lambda invoked when the Units per DIP of this composable MapView has changed

onSpatialReferenceChanged

lambda invoked when the spatial reference of the composable MapView has changed

onLayerViewStateChanged

lambda invoked when the composable MapView's layer view state is changed

onInteractingChanged

lambda invoked when the user starts and ends interacting with the composable MapView

onRotate

lambda invoked when a user performs a rotation gesture on the composable MapView

onScale

lambda invoked when a user performs a pinch gesture on the composable MapView

onUp

lambda invoked when the user removes all their pointers from the composable MapView

onDown

lambda invoked when the user first presses on the composable MapView

onSingleTapConfirmed

lambda invoked when the user taps once on the composable MapView

onDoubleTap

lambda invoked the user double taps on the composable MapView

onLongPress

lambda invoked when a user holds a pointer on the composable MapView

onTwoPointerTap

lambda invoked when a user taps two pointers on the composable MapView

onPan

lambda invoked when a user drags a pointer or pointers across composable MapView

onDrawStatusChanged

lambda invoked when the draw status of the composable MapView is changed

See also

Samples

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.arcgismaps.Color
import com.arcgismaps.data.ServiceFeatureTable
import com.arcgismaps.geometry.Point
import com.arcgismaps.geometry.SpatialReference
import com.arcgismaps.mapping.ArcGISMap
import com.arcgismaps.mapping.ArcGISScene
import com.arcgismaps.mapping.ArcGISTiledElevationSource
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.Surface
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.mapping.layers.FeatureLayer
import com.arcgismaps.mapping.symbology.SimpleLineSymbol
import com.arcgismaps.mapping.symbology.SimpleLineSymbolStyle
import com.arcgismaps.mapping.symbology.SimpleRenderer
import com.arcgismaps.mapping.view.Camera
import com.arcgismaps.toolkit.geoviewcompose.MapView
import com.arcgismaps.toolkit.geoviewcompose.SceneView
fun main() { 
   //sampleStart 
   // Display a feature layer in a MapView using a service feature table

// create a map to display a feature layer
val map by remember {
    mutableStateOf(ArcGISMap(BasemapStyle.ArcGISTopographic).apply {
        initialViewpoint = Viewpoint( // USA viewpoint
            center = Point(-11e6, 5e6, SpatialReference.webMercator()),
            scale = 1e8
        )
    })
}

// create a service feature table (which will be used to create a feature layer)
val serviceFeatureTable = ServiceFeatureTable(
    uri = "https://services.arcgis.com/jIL9msH9OI208GCb/arcgis/rest/services/USA_Daytime_Population_2016/FeatureServer/0"
)

// create the feature layer using the service feature table
val featureLayer: FeatureLayer = FeatureLayer.createWithFeatureTable(serviceFeatureTable)

// create symbol to show U.S. states with a black outline
val lineSymbol = SimpleLineSymbol(
    style = SimpleLineSymbolStyle.Solid,
    color = Color.black,
    width = 1.0f
)

// set feature layer properties
featureLayer.apply {
    // set renderer for the feature layer
    renderer = SimpleRenderer(lineSymbol)
    opacity = 0.8f
    maxScale = 10000.0
}

// add the feature layer to the map's operational layers
map.operationalLayers.add(featureLayer)

// display the Composable MapView
MapView(
    map,
    modifier = Modifier.fillMaxSize(),
) 
   //sampleEnd
}