Skip to content

Commit a92b761

Browse files
authored
Revisit Identify layer features sample (#177)
2 parents af0745a + 0535683 commit a92b761

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/MapViewModel.kt

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import androidx.lifecycle.AndroidViewModel
2323
import com.arcgismaps.data.ServiceFeatureTable
2424
import com.arcgismaps.mapping.ArcGISMap
2525
import com.arcgismaps.mapping.BasemapStyle
26+
import com.arcgismaps.mapping.Viewpoint
2627
import com.arcgismaps.mapping.layers.ArcGISMapImageLayer
2728
import com.arcgismaps.mapping.layers.FeatureLayer.Companion.createWithFeatureTable
2829
import com.arcgismaps.mapping.view.IdentifyLayerResult
@@ -71,14 +72,18 @@ class MapViewModel(
7172
}
7273

7374
// add the world cities layer with and the damaged properties feature layer
74-
map.operationalLayers.addAll(listOf(mapImageLayer, featureLayer))
75+
map.apply {
76+
// set initial Viewpoint to North America
77+
initialViewpoint = Viewpoint(39.8, -98.6, 5e7)
78+
operationalLayers.addAll(listOf(mapImageLayer, featureLayer))
79+
}
7580

7681
}
7782

7883
/**
7984
* Identify the feature layer results and display the resulting information
8085
*/
81-
fun handleIdentifyResult(result: Result<List<IdentifyLayerResult>>) {
86+
private fun handleIdentifyResult(result: Result<List<IdentifyLayerResult>>) {
8287
sampleCoroutineScope.launch {
8388
result.onSuccess { identifyResultList ->
8489
val message = StringBuilder()

identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/screens/MainScreen.kt

+1-13
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ import androidx.compose.runtime.rememberCoroutineScope
3131
import androidx.compose.ui.Modifier
3232
import androidx.compose.ui.platform.LocalContext
3333
import androidx.compose.ui.unit.dp
34-
import com.arcgismaps.geometry.Point
35-
import com.arcgismaps.geometry.SpatialReference
36-
import com.arcgismaps.mapping.Viewpoint
3734
import com.arcgismaps.toolkit.geocompose.MapView
38-
import com.arcgismaps.toolkit.geocompose.MapViewpointOperation
3935
import com.esri.arcgismaps.sample.identifylayerfeatures.components.MapViewModel
4036
import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog
4137
import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar
@@ -52,14 +48,7 @@ fun MainScreen(sampleName: String) {
5248
// create a ViewModel to handle MapView interactions
5349
val mapViewModel = remember { MapViewModel(sampleApplication, sampleCoroutineScope) }
5450
// create a Viewpoint
55-
val northAmericaViewpoint = Viewpoint(
56-
center = Point(
57-
x = -10977012.785807,
58-
y = 4514257.550369,
59-
spatialReference = SpatialReference(wkid = 3857)
60-
),
61-
scale = 68015210.0
62-
)
51+
6352

6453
Scaffold(
6554
topBar = { SampleTopAppBar(title = sampleName) },
@@ -75,7 +64,6 @@ fun MainScreen(sampleName: String) {
7564
.weight(1f)
7665
.animateContentSize(),
7766
arcGISMap = mapViewModel.map,
78-
viewpointOperation = MapViewpointOperation.Set(viewpoint = northAmericaViewpoint),
7967
mapViewProxy = mapViewModel.mapViewProxy,
8068
onSingleTapConfirmed = mapViewModel::identify
8169
)

0 commit comments

Comments
 (0)