- Nur ArcGIS Karte implementiert
- in toml arcgis libraries hinzugefügt - mindSdk von 27 auf 28 gesetzt
This commit is contained in:
@@ -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)
|
||||
}
|
||||
@@ -4,6 +4,9 @@
|
||||
<!-- Kamera Zugriffsberechtigung -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
<!-- ArcGIS Pro benötigt-->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
|
||||
@@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.arcgismaps.ApiKey
|
||||
import com.arcgismaps.ArcGISEnvironment
|
||||
import com.example.snapandsolve.camera.AlbumViewModel
|
||||
import com.example.snapandsolve.ui.theme.SnapAndSolveTheme
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -21,6 +23,11 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
viewModel = AlbumViewModel(coroutineContext = Dispatchers.Default)
|
||||
|
||||
/*
|
||||
Wird gebraucht um die Karte in ArcGIS anzuzeigen. Die Prüfung ob man Zugang hat oder nicht
|
||||
wurde gelöscht.
|
||||
*/
|
||||
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ARCGIS_TOKEN)
|
||||
enableEdgeToEdge()
|
||||
|
||||
setContent {
|
||||
|
||||
@@ -57,6 +57,10 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.arcgismaps.mapping.ArcGISMap
|
||||
import com.arcgismaps.mapping.BasemapStyle
|
||||
import com.arcgismaps.mapping.Viewpoint
|
||||
import com.arcgismaps.toolkit.geoviewcompose.MapView
|
||||
import com.example.snapandsolve.camera.AlbumViewModel
|
||||
import com.example.snapandsolve.camera.AlbumViewState
|
||||
import com.example.snapandsolve.camera.Intent
|
||||
@@ -130,10 +134,21 @@ fun ContentScreen(
|
||||
onDismissReport: () -> 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)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String> = 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user