Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit Identify layer features sample #177

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.unit.dp
import androidx.lifecycle.AndroidViewModel
import com.arcgismaps.data.ServiceFeatureTable
import com.arcgismaps.geometry.Point
import com.arcgismaps.geometry.SpatialReference
import com.arcgismaps.mapping.ArcGISMap
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.mapping.layers.ArcGISMapImageLayer
import com.arcgismaps.mapping.layers.FeatureLayer.Companion.createWithFeatureTable
import com.arcgismaps.mapping.view.IdentifyLayerResult
Expand Down Expand Up @@ -71,14 +74,25 @@ class MapViewModel(
}

// add the world cities layer with and the damaged properties feature layer
map.operationalLayers.addAll(listOf(mapImageLayer, featureLayer))
map.apply {
// set initial Viewpoint to North America
initialViewpoint = Viewpoint(
center = Point(
x = -10977012.785807,
y = 4514257.550369,
spatialReference = SpatialReference(wkid = 3857)
),
scale = 68015210.0
)
operationalLayers.addAll(listOf(mapImageLayer, featureLayer))
}

}

/**
* Identify the feature layer results and display the resulting information
*/
fun handleIdentifyResult(result: Result<List<IdentifyLayerResult>>) {
private fun handleIdentifyResult(result: Result<List<IdentifyLayerResult>>) {
sampleCoroutineScope.launch {
result.onSuccess { identifyResultList ->
val message = StringBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.arcgismaps.geometry.Point
import com.arcgismaps.geometry.SpatialReference
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.toolkit.geocompose.MapView
import com.arcgismaps.toolkit.geocompose.MapViewpointOperation
import com.esri.arcgismaps.sample.identifylayerfeatures.components.MapViewModel
import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog
import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar
Expand All @@ -52,14 +48,7 @@ fun MainScreen(sampleName: String) {
// create a ViewModel to handle MapView interactions
val mapViewModel = remember { MapViewModel(sampleApplication, sampleCoroutineScope) }
// create a Viewpoint
val northAmericaViewpoint = Viewpoint(
center = Point(
x = -10977012.785807,
y = 4514257.550369,
spatialReference = SpatialReference(wkid = 3857)
),
scale = 68015210.0
)


Scaffold(
topBar = { SampleTopAppBar(title = sampleName) },
Expand All @@ -75,7 +64,6 @@ fun MainScreen(sampleName: String) {
.weight(1f)
.animateContentSize(),
arcGISMap = mapViewModel.map,
viewpointOperation = MapViewpointOperation.Set(viewpoint = northAmericaViewpoint),
mapViewProxy = mapViewModel.mapViewProxy,
onSingleTapConfirmed = mapViewModel::identify
)
Expand Down
Loading