From 2f781abcc2a2e8e7fd2546335bc8a146783d539d Mon Sep 17 00:00:00 2001 From: si2503 Date: Fri, 19 Dec 2025 20:08:56 +0100 Subject: [PATCH] =?UTF-8?q?-=20Nur=20ArcGIS=20Karte=20implementiert=20-=20?= =?UTF-8?q?in=20toml=20arcgis=20libraries=20hinzugef=C3=BCgt=20-=20mindSdk?= =?UTF-8?q?=20von=2027=20auf=2028=20gesetzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/codeStyles/Project.xml | 123 ++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/deploymentTargetSelector.xml | 8 ++ app/build.gradle.kts | 9 +- app/src/main/AndroidManifest.xml | 3 + .../com/example/snapandsolve/MainActivity.kt | 7 + .../com/example/snapandsolve/MainScreen.kt | 34 ++++- .../com/example/snapandsolve/MapViewModel.kt | 56 ++++++++ gradle/libs.versions.toml | 5 + 9 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..7643783 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,123 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml index b268ef3..4bba6b0 100644 --- a/.idea/deploymentTargetSelector.xml +++ b/.idea/deploymentTargetSelector.xml @@ -4,6 +4,14 @@ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index eb29722..db034f2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,7 +12,7 @@ android { defaultConfig { applicationId = "com.example.snapandsolve" - minSdk = 27 + minSdk = 28 targetSdk = 36 versionCode = 1 versionName = "1.0" @@ -68,4 +68,11 @@ dependencies { debugImplementation(libs.androidx.compose.ui.test.manifest) implementation("androidx.compose.material:material-icons-core") implementation("androidx.compose.material:material-icons-extended") + + // ArcGIS Maps for Kotlin - SDK dependency + implementation(libs.arcgis.maps.kotlin) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) + implementation(libs.arcgis.maps.kotlin.toolkit.authentication) } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1f25f57..c091ed7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,9 @@ + + + Unit ) { val mapViewModel = remember { MapViewModel(application) } - // ViewModel für die Kamera-Funktionalität val albumViewModel = remember { AlbumViewModel(Dispatchers.Default) } + // ArcGIS Map erstellen + val map = remember { + createMap() //Funktion zur Erstellung der Map + } + Box(modifier = modifier.fillMaxSize()) { + // HINTERGRUND: Die Map + MapView( + modifier = Modifier.fillMaxSize(), + arcGISMap = map + ) + + // VORDERGRUND: Das Overlay (wenn showReport = true) if (showReport) { ReportOverlay( onCancel = onDismissReport, @@ -333,4 +348,21 @@ fun ReportOverlay( } } } + + +} + +fun createMap(): ArcGISMap { + + return ArcGISMap(BasemapStyle.ArcGISTopographic).apply { + + initialViewpoint = Viewpoint( + 53.14, + 8.20, + 20000.0) + + + + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/snapandsolve/MapViewModel.kt b/app/src/main/java/com/example/snapandsolve/MapViewModel.kt index 15aa574..772f85d 100644 --- a/app/src/main/java/com/example/snapandsolve/MapViewModel.kt +++ b/app/src/main/java/com/example/snapandsolve/MapViewModel.kt @@ -1,8 +1,64 @@ package com.example.snapandsolve import android.app.Application +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue import androidx.lifecycle.AndroidViewModel +import androidx.lifecycle.viewModelScope +import com.arcgismaps.data.ArcGISFeature +import com.arcgismaps.data.CodedValueDomain +import com.arcgismaps.data.ServiceFeatureTable +import com.arcgismaps.mapping.ArcGISMap +import com.arcgismaps.mapping.BasemapStyle +import com.arcgismaps.mapping.Viewpoint +import com.arcgismaps.mapping.layers.FeatureLayer +import com.arcgismaps.toolkit.geoviewcompose.MapViewProxy +import kotlinx.coroutines.launch class MapViewModel(application: Application ): AndroidViewModel(application) { + val map: ArcGISMap = ArcGISMap(BasemapStyle.OpenOsmStyle).apply { + initialViewpoint = Viewpoint(53.14, 8.20, 20000.0) + } + + /* + ALLES UNTER DIESEM KOMMENTAR WIRD NICHT GENUTZT. Aber EVENTUELL nötig zum einbinden von + Layer und Features. + */ + // Hold a reference to the selected feature. + var selectedFeature: ArcGISFeature? by mutableStateOf(null) + val mapViewProxy = MapViewProxy() + + //var currentFeatureOperation by mutableStateOf(FeatureOperationType.CREATE) + + lateinit var featureLayer: FeatureLayer + + // Create a snackbar message to display the result of feature operations. + var snackBarMessage: String by mutableStateOf("") + + lateinit var serviceFeatureTable: ServiceFeatureTable + + var currentDamageType by mutableStateOf("") + + // The list of damage types to update the feature attribute. + var damageTypeList: List = mutableListOf() + + init { + viewModelScope.launch { + serviceFeatureTable = ServiceFeatureTable("https://services9.arcgis.com/UVxdrlZq3S3gqt7w/ArcGIS/rest/services/StrassenSchaeden/FeatureServer/0") + serviceFeatureTable.load().onSuccess { + // Get the field from the feature table that will be updated. + val typeDamageField = serviceFeatureTable.fields.first { it.name == "Typ" } + // Get the coded value domain for the field. + val attributeDomain = typeDamageField.domain as CodedValueDomain + // Add the damage types to the list. + attributeDomain.codedValues.forEach { + damageTypeList += it.name + } + } + featureLayer = FeatureLayer.createWithFeatureTable(serviceFeatureTable) + map.operationalLayers.add(featureLayer) + } + } } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 25884ad..b72ef65 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ lifecycleRuntimeKtx = "2.10.0" activityCompose = "1.12.1" composeBom = "2024.09.00" material3 = "1.4.0" +arcgisMapsKotlin = "200.8.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -26,6 +27,10 @@ androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui- androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" } androidx-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "material3" } +arcgis-maps-kotlin = { group = "com.esri", name = "arcgis-maps-kotlin", version.ref = "arcgisMapsKotlin" } +arcgis-maps-kotlin-toolkit-bom = { group = "com.esri", name = "arcgis-maps-kotlin-toolkit-bom", version.ref = "arcgisMapsKotlin" } +arcgis-maps-kotlin-toolkit-geoview-compose = { group = "com.esri", name = "arcgis-maps-kotlin-toolkit-geoview-compose" } +arcgis-maps-kotlin-toolkit-authentication = { group = "com.esri", name = "arcgis-maps-kotlin-toolkit-authentication" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" }