diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2a4973cc7..01080968f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] # ArcGIS Maps SDK for Kotlin version -arcgisMapsKotlinVersion = "200.5.0-4223" +arcgisMapsKotlinVersion = "200.5.0-4244" # SDK versions compileSdk = "34" minSdk = "26" diff --git a/snap-geometry-edits/README.md b/snap-geometry-edits/README.md index 34ddbc020..45f50932b 100644 --- a/snap-geometry-edits/README.md +++ b/snap-geometry-edits/README.md @@ -12,11 +12,11 @@ A field worker can create new features by editing and snapping the vertices of a To create a geometry, press the create button to choose the geometry type you want to create (i.e. points, multipoints, polyline, or polygon) and interactively tap and drag on the map view to create the geometry. -To configure snapping, press the snap settings button to enable or disable snapping and choose which layers to snap to. +To configure snapping, press the snap settings button to enable or disable snapping and choose which snap sources to snap to. -To interactively snap a vertex, ensure that snapping is enabled and move the mouse pointer or drag a vertex to nearby an existing feature. When the pointer is close to a feature, the edit position will be adjusted to coincide with (or snap to), edges and vertices of that feature. Click or release the touch pointer to place the vertex at the snapped location. +To interactively snap a vertex to a feature or graphic, ensure that snapping is enabled for the relevant snap source and move the mouse pointer or drag a vertex to nearby an existing feature or graphic. When the pointer is close to that existing geoelement, the edit position will be adjusted to coincide with (or snap to), edges and vertices of its geometry. Click or release the touch pointer to place the vertex at the snapped location. -To edit a geometry, tap the geometry to be edited in the map to select it and then edit the geometry by tapping and dragging its vertices and snapping them to nearby features. +To edit a geometry, tap the geometry to be edited in the map to select it and then edit the geometry by tapping and dragging its vertices and snapping them to nearby features or graphics. To edit a vertex using the magnifier, tap and hold on the vertex and then drag it along with the magnifier. @@ -41,6 +41,7 @@ To save your edits, press the save button. * Geometry * GeometryEditor * GeometryEditorStyle +* GraphicsOverlay * MapView * MapView.interactionOptions.isMagnifierEnabled * SnapSettings @@ -63,4 +64,4 @@ Snapping can be used during interactive edits that move existing vertices using ## Tags -edit, feature, geometryeditor, geoviewcompose, layers, magnify, map, snapping +edit, feature, geometryeditor, geoviewcompose, graphics, layers, magnify, map, snapping diff --git a/snap-geometry-edits/README.metadata.json b/snap-geometry-edits/README.metadata.json index 0427af8af..a801e3e16 100644 --- a/snap-geometry-edits/README.metadata.json +++ b/snap-geometry-edits/README.metadata.json @@ -11,6 +11,7 @@ "feature", "geometryeditor", "geoviewcompose", + "graphics", "layers", "magnify", "map", @@ -19,6 +20,7 @@ "Geometry", "GeometryEditor", "GeometryEditorStyle", + "GraphicsOverlay", "MapView", "MapView.interactionOptions.isMagnifierEnabled", "SnapSettings", @@ -32,6 +34,7 @@ "Geometry", "GeometryEditor", "GeometryEditorStyle", + "GraphicsOverlay", "MapView", "MapView.interactionOptions.isMagnifierEnabled", "SnapSettings", diff --git a/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/components/MapViewModel.kt b/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/components/MapViewModel.kt index 286b0eb4b..5c4ada313 100644 --- a/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/components/MapViewModel.kt +++ b/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/components/MapViewModel.kt @@ -79,7 +79,9 @@ class MapViewModel( */ init { sampleCoroutineScope.launch { - // set the feature layer's feature tiling mode + // set the id for the graphics overlay + graphicsOverlay.id = "Editor Graphics Overlay" + // set the feature layer's tiling mode map.loadSettings.featureTilingMode = FeatureTilingMode.EnabledWithFullResolutionWhenSupported // load the map @@ -194,12 +196,13 @@ class MapViewModel( * more elements in the geometry. */ fun deleteSelection() { + if (geometryEditor.geometry.value?.isEmpty == true) { + geometryEditor.stop() + isCreateButtonEnabled.value = true + } + if (geometryEditor.selectedElement.value != null) { geometryEditor.deleteSelectedElement() - if (geometryEditor.geometry.value?.isEmpty == true) { - geometryEditor.stop() - isCreateButtonEnabled.value = true - } } } diff --git a/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/MainScreen.kt b/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/MainScreen.kt index add1f8c41..84802118d 100644 --- a/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/MainScreen.kt +++ b/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/MainScreen.kt @@ -49,13 +49,13 @@ fun MainScreen(sampleName: String) { val graphicsOverlayCollection = listOf(mapViewModel.graphicsOverlay) Scaffold( - topBar = { SampleTopAppBar(title = sampleName) }, content = { Column( modifier = Modifier .fillMaxSize() .padding(it) ) { + SampleTopAppBar(title = sampleName) MapView( modifier = Modifier .fillMaxSize() diff --git a/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/SnapSettingsScreen.kt b/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/SnapSettingsScreen.kt index c0defd830..c14f1aab2 100644 --- a/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/SnapSettingsScreen.kt +++ b/snap-geometry-edits/src/main/java/com/esri/arcgismaps/sample/snapgeometryedits/screens/SnapSettingsScreen.kt @@ -38,6 +38,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.arcgismaps.geometry.GeometryType import com.arcgismaps.mapping.layers.FeatureLayer +import com.arcgismaps.mapping.view.GraphicsOverlay import com.arcgismaps.mapping.view.geometryeditor.SnapSourceSettings import com.esri.arcgismaps.sample.sampleslib.theme.SampleTypography @@ -126,117 +127,103 @@ fun SnapSettings( } } } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(20.dp, 10.dp, 20.dp, 10.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween - ) { - Text( - style = SampleTypography.titleMedium, - text = "Point Layers", - color = MaterialTheme.colorScheme.primary - ) - TextButton( - onClick = { - snapSourceList.value.forEachIndexed { index, snapSource -> - if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Point) { - onSnapSourceChanged(true, index) - } - } - } - ) { - Text(text = "Enable All Sources") + SnapSourceUI(snapSourceList, isSnapSourceEnabled, onSnapSourceChanged, GeometryType.Point) + SnapSourceUI(snapSourceList, isSnapSourceEnabled, onSnapSourceChanged, GeometryType.Polyline) + SnapSourceUI(snapSourceList, isSnapSourceEnabled, onSnapSourceChanged, null) + } + } + } +} + +@Composable +fun SnapSourceUI( + snapSourceList: State>, + isSnapSourceEnabled: List, + onSnapSourceChanged: (Boolean, Int) -> Unit, + geometryType : GeometryType? +) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(20.dp, 10.dp, 20.dp, 10.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + style = SampleTypography.titleMedium, + text = when (geometryType) { + is GeometryType.Point -> "Point Layer" + is GeometryType.Polyline -> "Polyline Layer" + else -> "Graphics Overlays" + }, + color = MaterialTheme.colorScheme.primary + ) + TextButton( + onClick = { + snapSourceList.value.forEachIndexed { index, snapSource -> + if (geometryType != null && + (snapSource.source as? FeatureLayer)?.featureTable?.geometryType == geometryType) { + onSnapSourceChanged(true, index) + } else if (geometryType == null && snapSource.source is GraphicsOverlay) { + onSnapSourceChanged(true, index) } } - Surface( - modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp), - tonalElevation = 1.dp, - shape = RoundedCornerShape(20.dp), - border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant) - ) { - Column( - modifier = Modifier.padding(14.dp) - ) { - Column { - snapSourceList.value.forEachIndexed { index, snapSource -> - if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Point) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween - ) { - Text( - modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp), - text = (snapSource.source as FeatureLayer).name - ) - Switch( - checked = isSnapSourceEnabled[index], - onCheckedChange = { newValue -> - onSnapSourceChanged(newValue, index) - } - ) - } - } - } - } - } + } + ) { + Text( + text = if (geometryType != null) { + "Enable All Layers" + } else { + "Enable All Overlays" } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(20.dp, 0.dp, 20.dp, 10.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween - ) { - Text( - style = SampleTypography.titleMedium, - text = "Polyline Layers", - color = MaterialTheme.colorScheme.primary - ) - TextButton( - onClick = { - snapSourceList.value.forEachIndexed { index, snapSource -> - if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Polyline) { - onSnapSourceChanged(true, index) + ) + } + } + Surface( + modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp), + tonalElevation = 1.dp, + shape = RoundedCornerShape(20.dp), + border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant) + ) { + Column( + modifier = Modifier.padding(14.dp) + ) { + Column { + snapSourceList.value.forEachIndexed { index, snapSource -> + if (geometryType != null && + (snapSource.source as? FeatureLayer)?.featureTable?.geometryType == geometryType) { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp), + text = (snapSource.source as FeatureLayer).name + ) + Switch( + checked = isSnapSourceEnabled[index], + onCheckedChange = { newValue -> + onSnapSourceChanged(newValue, index) } - } + ) } - ) { - Text(text = "Enable All Sources") - } - } - Surface( - modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp), - tonalElevation = 1.dp, - shape = RoundedCornerShape(20.dp), - border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant) - ) { - Column( - modifier = Modifier.padding(14.dp) - ) { - Column { - snapSourceList.value.forEachIndexed { index, snapSource -> - if ((snapSource.source as FeatureLayer).featureTable?.geometryType == GeometryType.Polyline) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween - ) { - Text( - modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp), - text = (snapSource.source as FeatureLayer).name - ) - Switch( - checked = isSnapSourceEnabled[index], - onCheckedChange = { newValue -> - onSnapSourceChanged(newValue, index) - } - ) - } + } else if (geometryType == null && snapSource.source is GraphicsOverlay) { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + modifier = Modifier.padding(20.dp, 0.dp, 0.dp, 0.dp), + text = (snapSource.source as GraphicsOverlay).id + ) + Switch( + checked = isSnapSourceEnabled[index], + onCheckedChange = { newValue -> + onSnapSourceChanged(newValue, index) } - } + ) } } }