From b5e0c8a25c4bb13d1b8f2095a68f36fd327ee484 Mon Sep 17 00:00:00 2001 From: Ruiqi Ma Date: Thu, 7 Mar 2024 15:15:05 -0800 Subject: [PATCH 1/2] reflect changes in toolkit --- .../queryfeaturetable/components/MapViewModel.kt | 15 +++++++++------ .../queryfeaturetable/screens/MainScreen.kt | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt index 772d7f88d..c37ba2be1 100644 --- a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt +++ b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt @@ -36,7 +36,7 @@ import com.arcgismaps.mapping.symbology.SimpleFillSymbolStyle import com.arcgismaps.mapping.symbology.SimpleLineSymbol import com.arcgismaps.mapping.symbology.SimpleLineSymbolStyle import com.arcgismaps.mapping.symbology.SimpleRenderer -import com.arcgismaps.toolkit.geocompose.MapViewpointOperation +import com.arcgismaps.toolkit.geocompose.MapViewProxy import com.esri.arcgismaps.sample.queryfeaturetable.R import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel import kotlinx.coroutines.CoroutineScope @@ -44,7 +44,7 @@ import kotlinx.coroutines.launch import java.util.Locale class MapViewModel( - private val application: Application, + application: Application, private val sampleCoroutineScope: CoroutineScope ) : AndroidViewModel(application) { @@ -69,8 +69,8 @@ class MapViewModel( scale = 1e8 ) - // define a mutable MapViewpointOperation and set the initial viewpoint - var mapViewpointOperation: MapViewpointOperation by mutableStateOf(MapViewpointOperation.Set(usaViewpoint)) + // create a MapViewProxy to handle MapView operations + var mapViewProxy by mutableStateOf(MapViewProxy()) init { // use symbols to show U.S. states with a black outline and yellow fill @@ -93,7 +93,10 @@ class MapViewModel( maxScale = 10000.0 } // add the feature layer to the map's operational layers - map.operationalLayers.add(featureLayer) + map.apply { + initialViewpoint = usaViewpoint + operationalLayers.add(featureLayer) + } } /** @@ -123,7 +126,7 @@ class MapViewModel( val envelope = feature.geometry?.extent ?: return@launch messageDialogVM.showMessageDialog("Error retrieving geometry extent") // update the viewpoint to the bounding geometry of the returned feature - mapViewpointOperation = MapViewpointOperation.SetBoundingGeometry(envelope) + mapViewProxy.setViewpointGeometry(envelope) } else { messageDialogVM.showMessageDialog("No states found with name: $searchQuery") } diff --git a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt index 547e8a30f..a79d72c1c 100644 --- a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt +++ b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt @@ -56,7 +56,7 @@ fun MainScreen(sampleName: String) { .fillMaxWidth() .weight(1f), arcGISMap = mapViewModel.map, - viewpointOperation = mapViewModel.mapViewpointOperation + mapViewProxy = mapViewModel.mapViewProxy ) SearchBar( modifier = Modifier.fillMaxWidth(), From c4bfb000a9fb9e270a4cd57e36014783f9737b9b Mon Sep 17 00:00:00 2001 From: Ruiqi Ma Date: Fri, 15 Mar 2024 10:34:42 -0700 Subject: [PATCH 2/2] resolve comments --- .../sample/queryfeaturetable/components/MapViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt index c37ba2be1..0fdb5e26e 100644 --- a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt +++ b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt @@ -125,7 +125,7 @@ class MapViewModel( // get the extent of the first feature in the result to zoom to val envelope = feature.geometry?.extent ?: return@launch messageDialogVM.showMessageDialog("Error retrieving geometry extent") - // update the viewpoint to the bounding geometry of the returned feature + // update the map's viewpoint to the feature's geometry mapViewProxy.setViewpointGeometry(envelope) } else { messageDialogVM.showMessageDialog("No states found with name: $searchQuery")