Skip to content

Deprecate composable-map #293

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

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 0 additions & 1 deletion microapps/AuthenticationApp/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ android {

dependencies {
implementation(project(":authentication"))
implementation(project(":composable-map"))
implementation(arcgis.mapsSdk)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.bundles.composeCore)
Expand Down
2 changes: 1 addition & 1 deletion microapps/CompassApp/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all {

dependencies {
implementation(project(":compass"))
implementation(project(":composable-map"))
implementation(project(":geo-compose"))
implementation(arcgis.mapsSdk)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.bundles.composeCore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.arcgismaps.toolkit.compassapp.screens

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -26,40 +27,51 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.arcgismaps.mapping.ArcGISMap
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.toolkit.compass.Compass
import com.arcgismaps.toolkit.composablemap.ComposableMap
import com.arcgismaps.toolkit.composablemap.DuplexFlow
import com.arcgismaps.toolkit.geocompose.MapView
import com.arcgismaps.toolkit.geocompose.MapViewpointOperation

@Composable
fun MainScreen() {
// create an ArcGISMap with a Topographic basemap style
val map = ArcGISMap(BasemapStyle.ArcGISTopographic)
// instantiate a MapViewModel using the factory
val mapViewModel = viewModel<MapViewModel>(factory = MapViewModelFactory(map))
// hoist the mapRotation state
val mapRotation by mapViewModel.mapRotation.collectAsState(DuplexFlow.Type.Read)
// show a composable map using the mapViewModel
ComposableMap(
modifier = Modifier.fillMaxSize(),
mapInterface = mapViewModel
val arcGISMap by remember { mutableStateOf(ArcGISMap(BasemapStyle.ArcGISTopographic)) }
// set the composable map's viewpoint to North America
var mapViewpointOperation: MapViewpointOperation? by remember {
mutableStateOf(
MapViewpointOperation.Set(Viewpoint(39.8, -98.6, 10e7))
)
}
var mapRotation by remember { mutableDoubleStateOf(0.0) }
// show composable MapView with compass
Box(
modifier = Modifier.fillMaxSize()
) {
Row(modifier = Modifier
.height(IntrinsicSize.Max)
.fillMaxWidth()
.padding(25.dp)) {
MapView(
modifier = Modifier.fillMaxSize(),
arcGISMap = arcGISMap,
viewpointOperation = mapViewpointOperation,
onMapRotationChanged = { rotation -> mapRotation = rotation }
)
Row(
modifier = Modifier
.height(IntrinsicSize.Max)
.fillMaxWidth()
.padding(25.dp)
) {
// show the compass and pass the mapRotation state data
Compass(rotation = mapRotation) {
// reset the ComposableMap viewpoint rotation to point north using the mapViewModel
mapViewModel.setViewpointRotation(0.0)
// reset the Composable MapView viewpoint rotation to point north
mapViewpointOperation = MapViewpointOperation.Rotate(0.0)
}
}
}
// set the composable map's viewpoint to North America
mapViewModel.setViewpoint(Viewpoint(39.8, -98.6, 10e7))
}

This file was deleted.

2 changes: 1 addition & 1 deletion microapps/FloorFilterApp/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all {

dependencies {
implementation(project(":indoors"))
implementation(project(":composable-map"))
implementation(project(":geo-compose"))
implementation(arcgis.mapsSdk)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.bundles.composeCore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,93 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.arcgismaps.geometry.Envelope
import com.arcgismaps.geometry.Geometry
import com.arcgismaps.mapping.ArcGISMap
import com.arcgismaps.mapping.PortalItem
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.portal.Portal
import com.arcgismaps.toolkit.composablemap.ComposableMap
import com.arcgismaps.toolkit.geocompose.MapView
import com.arcgismaps.toolkit.geocompose.MapViewpointOperation
import com.arcgismaps.toolkit.indoors.FloorFilter
import com.arcgismaps.toolkit.indoors.FloorFilterSelection
import com.arcgismaps.toolkit.indoors.FloorFilterState

@Composable
fun MainScreen() {
val portal = Portal("https://arcgis.com/")
val portalItem = PortalItem(portal, "b4b599a43a474d33946cf0df526426f5")
val floorAwareWebMap = ArcGISMap(portalItem)
val floorAwareWebMap by remember {
mutableStateOf(
ArcGISMap(
PortalItem(
Portal("https://arcgis.com/"),
"b4b599a43a474d33946cf0df526426f5"
)
)
)
}

var mapViewpointOperation: MapViewpointOperation? by remember { mutableStateOf(null) }

val coroutineScope = rememberCoroutineScope()

// use default UI properties
val floorFilterState: FloorFilterState by remember {
mutableStateOf(FloorFilterState(
geoModel = floorAwareWebMap,
coroutineScope = coroutineScope
) { floorFilterSelection ->
when (floorFilterSelection.type) {
is FloorFilterSelection.Type.FloorSite -> {
val floorFilterSelectionType =
floorFilterSelection.type as FloorFilterSelection.Type.FloorSite
floorFilterSelectionType.site.geometry?.let {
mapViewpointOperation =
MapViewpointOperation.Set(Viewpoint(getEnvelopeWithBuffer(it)))
}
}

is FloorFilterSelection.Type.FloorFacility -> {
val floorFilterSelectionType =
floorFilterSelection.type as FloorFilterSelection.Type.FloorFacility
floorFilterSelectionType.facility.geometry?.let {
mapViewpointOperation =
MapViewpointOperation.Set(Viewpoint(getEnvelopeWithBuffer(it)))
}
}

val mapViewModel = viewModel<MapViewModel>(factory = MapViewModelFactory(floorAwareWebMap))
else -> {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log something to the screen instead?

Copy link
Collaborator Author

@puneet-pdx puneet-pdx Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't be of any help, as the third FloorFilterSelection.Type is FloorLevel and we are not setting the viewpoint related to the level for this example. This block is just to show the user how they can refocus the viewpoint of the map to the selected site and facility. We left the level out of it. This logic hasn't changed with this refactor.

}
})
}

ComposableMap(
MapView(
modifier = Modifier.fillMaxSize(),
mapInterface = mapViewModel
arcGISMap = floorAwareWebMap,
viewpointOperation = mapViewpointOperation
)
Box(
modifier = Modifier.fillMaxSize().padding(horizontal = 20.dp, vertical = 40.dp),
contentAlignment = Alignment.BottomStart
) {
Box(
modifier = Modifier.fillMaxSize().padding(horizontal = 20.dp, vertical = 40.dp),
contentAlignment = Alignment.BottomStart
) {
FloorFilter(floorFilterState = mapViewModel.floorFilterState)
}
FloorFilter(floorFilterState = floorFilterState)
}
}

/**
* Returns the envelope with an added buffer factor applied to the given Geometry's extent.
*
* @since 200.2.0
*/
private fun getEnvelopeWithBuffer(geometry: Geometry): Envelope {
val bufferFactor = 1.25
val envelope = geometry.extent
return Envelope(envelope.center, envelope.width * bufferFactor, envelope.height * bufferFactor)
}

This file was deleted.

3 changes: 2 additions & 1 deletion toolkit/composable-map/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Composable Map
# Composable Map[Deprecated]
This module is deprecated. Use https://github.com/Esri/arcgis-maps-sdk-kotlin-toolkit/tree/main/toolkit/geo-compose instead.

## DuplexFlow

Expand Down
2 changes: 2 additions & 0 deletions toolkit/composable-map/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*/

logger.warn("WARNING: The module composable-map is deprecated. Please use the module geo-compose instead.")

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.arcgismaps.mapping.ViewpointType
import com.arcgismaps.mapping.view.MapView
import kotlinx.coroutines.launch

@Deprecated("Use the new composable MapView function available in the geo-compose toolkit component instead")
@Composable
public fun ComposableMap(
mapInterface: MapInterface,
Expand Down