Skip to content

Commit 3a268fc

Browse files
pjleonard37Release SDK bot for Maps SDK team
authored andcommitted
Update Interactions API implementation on Standard & Standard Satellite (#3754)
This PR updates the Interactions API for the `MapboxStandardStyle` and `MapboxStandardSatelliteStyle` styles. Specifically, it: * Adds common `MapInteraction` APIs to `StandardStyleInteractionsState`: `.onFeaturesetClicked`, `.onLayerClicked`, `.onFeaturesetLongClicked`, `.onLayerLongClicked`, `.onMapClicked`, `.onMapLongClicked`. * Updates the template as this is generated * Adds `StyleInteractionsState` to `MapboxStandardSatelliteStyle` so the common interactions can be used with the satellite style. * Updates the Interactions example to take advantage of these new APIs. * Removes several other Experimental designations cc @mapbox/sdk-ci --------- Co-authored-by: Release SDK bot for Maps SDK team <[email protected]> GitOrigin-RevId: 975e03f3635d7a80de12e94af4921d36fd4b59e0
1 parent dee1626 commit 3a268fc

File tree

9 files changed

+311
-42
lines changed

9 files changed

+311
-42
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Mapbox welcomes participation and contributions from everyone.
77
* Expose `RenderThreadStatsRecorder` as experimental API.
88
* Expose new experimental properties: `CircleLayer.circleElevationReference`, `FillLayer.fillConstructBridgeGuardRail`, `FillLayer.fillBridgeGuardRailColor`, `FillLayer.fillTunnelStructureColor`.
99
* Promote `MapInteraction` APIs to stable, remove experimental `Style.STANDARD_EXPERIMENTAL` constant, as `Style.STANDARD` supports featuresets and map interactions by default.
10+
* Add common `MapInteraction` APIs to `StandardStyleInteractionsState`: `.onFeaturesetClicked`, `.onLayerClicked`, `.onFeaturesetLongClicked`, `.onLayerLongClicked`, `.onMapClicked`, `.onMapLongClicked`.
11+
* Add `StyleInteractionsState` to `MapboxStandardSatelliteStyle` so interactions can be used with the satellite style.
1012
* [compose] Rename experimental `ExperimentalStandardStyleState` to `StandardStyleState`, rename experimental `MapboxStandardStyleExperimental` to `MapboxStandardStyle(styleImportsContent, topSlot, middleSlot, bottomSlot, standardStyleState)`, and deprecate previous `MapboxStandardStyle` composable functions.
1113

1214
# 11.12.0 May 7, 2025

compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/style/InteractionsActivity.kt

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,20 @@ import androidx.compose.ui.text.style.TextAlign
2424
import androidx.compose.ui.unit.dp
2525
import com.mapbox.geojson.Point
2626
import com.mapbox.maps.EdgeInsets
27-
import com.mapbox.maps.MapboxExperimental
2827
import com.mapbox.maps.compose.testapp.ExampleScaffold
2928
import com.mapbox.maps.compose.testapp.ui.theme.MapboxMapComposeTheme
3029
import com.mapbox.maps.dsl.cameraOptions
3130
import com.mapbox.maps.extension.compose.MapboxMap
3231
import com.mapbox.maps.extension.compose.animation.viewport.rememberMapViewportState
3332
import com.mapbox.maps.extension.compose.rememberMapState
34-
import com.mapbox.maps.extension.compose.style.GenericStyle
35-
import com.mapbox.maps.extension.compose.style.rememberStyleState
33+
import com.mapbox.maps.extension.compose.style.imports.rememberStyleImportState
34+
import com.mapbox.maps.extension.compose.style.standard.MapboxStandardStyle
35+
import com.mapbox.maps.extension.compose.style.standard.rememberStandardStyleState
3636
import com.mapbox.maps.interactions.FeatureState
3737
import com.mapbox.maps.interactions.FeatureStateKey
3838
import com.mapbox.maps.interactions.FeaturesetFeature
3939

4040
public class InteractionsActivity : ComponentActivity() {
41-
42-
@OptIn(MapboxExperimental::class)
4341
override fun onCreate(savedInstanceState: Bundle?) {
4442
super.onCreate(savedInstanceState)
4543

@@ -88,31 +86,39 @@ public class InteractionsActivity : ComponentActivity() {
8886
mapState = mapState,
8987
mapViewportState = mapViewportState,
9088
style = {
91-
GenericStyle(
92-
style = "asset://fragment-realestate-NY.json",
93-
styleState = rememberStyleState {
94-
styleInteractionsState
95-
.onFeaturesetClicked(id = "hotels-price") { priceLabel, _ ->
96-
if (selectedPriceLabel?.id != priceLabel.id) {
97-
selectedPriceLabel?.removeFeatureState(FeatureStateKey.create("active"))
98-
selectedPriceLabel = priceLabel
99-
}
100-
val newActiveState = priceLabel.state.getBooleanState("active")?.not() ?: true
101-
priceLabel.setFeatureState(
102-
FeatureState {
103-
addBooleanState("active", newActiveState)
104-
}
105-
) {
106-
isActive = newActiveState
107-
}
108-
return@onFeaturesetClicked true
109-
}
89+
MapboxStandardStyle(
90+
standardStyleState = rememberStandardStyleState {
91+
interactionsState
11092
.onMapClicked {
11193
selectedPriceLabel?.removeFeatureState(FeatureStateKey.create("active"))
11294
selectedPriceLabel = null
11395
isActive = null
11496
true
11597
}
98+
},
99+
styleImportsContent = {
100+
StyleImport(
101+
importId = "realestate",
102+
style = "asset://fragment-realestate-NY.json",
103+
styleImportState = rememberStyleImportState {
104+
interactionsState
105+
.onFeaturesetClicked(id = "hotels-price") { priceLabel, _ ->
106+
if (selectedPriceLabel?.id != priceLabel.id) {
107+
selectedPriceLabel?.removeFeatureState(FeatureStateKey.create("active"))
108+
selectedPriceLabel = priceLabel
109+
}
110+
val newActiveState = priceLabel.state.getBooleanState("active")?.not() ?: true
111+
priceLabel.setFeatureState(
112+
FeatureState {
113+
addBooleanState("active", newActiveState)
114+
}
115+
) {
116+
isActive = newActiveState
117+
}
118+
return@onFeaturesetClicked true
119+
}
120+
}
121+
)
116122
}
117123
)
118124
}

extension-compose/api/extension-compose.api

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4291,6 +4291,8 @@ public final class com/mapbox/maps/extension/compose/style/standard/LightPresetV
42914291
}
42924292

42934293
public final class com/mapbox/maps/extension/compose/style/standard/MapboxStandardSatelliteStyleKt {
4294+
public static final fun MapboxStandardSatelliteStyle (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;Lcom/mapbox/maps/extension/compose/style/interactions/StyleInteractionsState;Lcom/mapbox/maps/extension/compose/style/standard/StandardSatelliteStyleConfigurationState;Landroidx/compose/runtime/Composer;III)V
4295+
public static final fun MapboxStandardSatelliteStyle (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;Lcom/mapbox/maps/extension/compose/style/interactions/StyleInteractionsState;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;III)V
42944296
public static final fun MapboxStandardSatelliteStyle (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;Lcom/mapbox/maps/extension/compose/style/standard/StandardSatelliteStyleConfigurationState;Landroidx/compose/runtime/Composer;II)V
42954297
public static final fun MapboxStandardSatelliteStyle (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V
42964298
}
@@ -4357,6 +4359,16 @@ public final class com/mapbox/maps/extension/compose/style/standard/generated/St
43574359
public static synthetic fun onBuildingsClicked$default (Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
43584360
public final fun onBuildingsLongClicked (Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
43594361
public static synthetic fun onBuildingsLongClicked$default (Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4362+
public final fun onFeaturesetClicked (Ljava/lang/String;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4363+
public static synthetic fun onFeaturesetClicked$default (Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;Ljava/lang/String;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4364+
public final fun onFeaturesetLongClicked (Ljava/lang/String;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4365+
public static synthetic fun onFeaturesetLongClicked$default (Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;Ljava/lang/String;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4366+
public final fun onLayerClicked (Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4367+
public static synthetic fun onLayerClicked$default (Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4368+
public final fun onLayerLongClicked (Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4369+
public static synthetic fun onLayerLongClicked$default (Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4370+
public final fun onMapClicked (Lkotlin/jvm/functions/Function2;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
4371+
public final fun onMapLongClicked (Lkotlin/jvm/functions/Function2;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
43604372
public final fun onPlaceLabelsClicked (Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
43614373
public static synthetic fun onPlaceLabelsClicked$default (Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;
43624374
public final fun onPlaceLabelsLongClicked (Ljava/lang/String;Lcom/mapbox/maps/extension/style/expressions/generated/Expression;Ljava/lang/Double;Lkotlin/jvm/functions/Function3;)Lcom/mapbox/maps/extension/compose/style/standard/generated/StandardStyleInteractionsState;

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/StyleState.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public class StyleState internal constructor(
7272
/**
7373
* The [StyleInteractionsState] manages the map interactions defined for the style.
7474
*/
75-
@MapboxExperimental
7675
public var styleInteractionsState: StyleInteractionsState by mutableStateOf(
7776
initialStyleInteractionsState
7877
)

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/imports/StyleImportInteractionsState.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import androidx.compose.runtime.remember
66
import com.mapbox.maps.ClickInteraction
77
import com.mapbox.maps.InteractionContext
88
import com.mapbox.maps.LongClickInteraction
9-
import com.mapbox.maps.MapboxExperimental
109
import com.mapbox.maps.MapboxMap
1110
import com.mapbox.maps.extension.compose.style.interactions.BasicStyleInteractions
1211
import com.mapbox.maps.extension.compose.style.interactions.generated.FeaturesetFeatureScope
@@ -21,7 +20,6 @@ import com.mapbox.maps.interactions.FeaturesetFeature
2120
*
2221
* @return [StyleImportInteractionsState]
2322
*/
24-
@MapboxExperimental
2523
@Composable
2624
public inline fun rememberStyleImportInteractionsState(crossinline init: StyleImportInteractionsState.() -> Unit = {}): StyleImportInteractionsState {
2725
return remember {
@@ -33,7 +31,6 @@ public inline fun rememberStyleImportInteractionsState(crossinline init: StyleIm
3331
* [StyleImportInteractionsState] manages the map interactions defined for the style import.
3432
*/
3533
@Stable
36-
@MapboxExperimental
3734
public class StyleImportInteractionsState : BasicStyleInteractions() {
3835

3936
@Composable
@@ -52,7 +49,6 @@ public class StyleImportInteractionsState : BasicStyleInteractions() {
5249
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
5350
* @param onClick callback triggered when featureset is clicked.
5451
*/
55-
@MapboxExperimental
5652
public fun onFeaturesetClicked(
5753
id: String,
5854
importId: String? = null,
@@ -80,7 +76,6 @@ public class StyleImportInteractionsState : BasicStyleInteractions() {
8076
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
8177
* @param onLongClick callback triggered when featureset is clicked.
8278
*/
83-
@MapboxExperimental
8479
public fun onFeaturesetLongClicked(
8580
id: String,
8681
importId: String? = null,
@@ -104,7 +99,6 @@ public class StyleImportInteractionsState : BasicStyleInteractions() {
10499
*
105100
* @param onClick callback triggered when map surface is clicked.
106101
*/
107-
@MapboxExperimental
108102
public fun onMapClicked(
109103
onClick: FeaturesetFeatureScope.(InteractionContext) -> Boolean
110104
): StyleImportInteractionsState = apply {
@@ -118,7 +112,6 @@ public class StyleImportInteractionsState : BasicStyleInteractions() {
118112
*
119113
* @param onLongClick callback triggered when map surface is clicked.
120114
*/
121-
@MapboxExperimental
122115
public fun onMapLongClicked(
123116
onLongClick: FeaturesetFeatureScope.(InteractionContext) -> Boolean
124117
): StyleImportInteractionsState = apply {

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/imports/StyleImportState.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class StyleImportState internal constructor(
5151
/**
5252
* The [StyleImportInteractionsState] defined for the imported style.
5353
*/
54-
@MapboxExperimental
5554
public var interactionsState: StyleImportInteractionsState by mutableStateOf(initialStyleImportInteractionsState)
5655

5756
/**

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/interactions/StyleInteractionsState.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import androidx.compose.runtime.remember
66
import com.mapbox.maps.ClickInteraction
77
import com.mapbox.maps.InteractionContext
88
import com.mapbox.maps.LongClickInteraction
9-
import com.mapbox.maps.MapboxExperimental
109
import com.mapbox.maps.MapboxMap
1110
import com.mapbox.maps.extension.compose.style.interactions.generated.FeaturesetFeatureScope
1211
import com.mapbox.maps.extension.style.expressions.generated.Expression
@@ -20,7 +19,6 @@ import com.mapbox.maps.interactions.FeaturesetFeature
2019
*
2120
* @return [StyleInteractionsState]
2221
*/
23-
@MapboxExperimental
2422
@Composable
2523
public inline fun rememberStyleInteractionStates(crossinline init: StyleInteractionsState.() -> Unit = {}): StyleInteractionsState {
2624
return remember {
@@ -32,7 +30,6 @@ public inline fun rememberStyleInteractionStates(crossinline init: StyleInteract
3230
* [StyleInteractionsState] manages the map interactions defined for the style.
3331
*/
3432
@Stable
35-
@MapboxExperimental
3633
public class StyleInteractionsState : BasicStyleInteractions() {
3734

3835
@Composable
@@ -51,7 +48,6 @@ public class StyleInteractionsState : BasicStyleInteractions() {
5148
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
5249
* @param onClick callback triggered when featureset is clicked.
5350
*/
54-
@MapboxExperimental
5551
public fun onFeaturesetClicked(
5652
id: String,
5753
importId: String? = null,
@@ -78,7 +74,6 @@ public class StyleInteractionsState : BasicStyleInteractions() {
7874
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
7975
* @param onClick callback triggered when layer is clicked.
8076
*/
81-
@MapboxExperimental
8277
public fun onLayerClicked(
8378
id: String,
8479
filter: Expression? = null,
@@ -99,7 +94,6 @@ public class StyleInteractionsState : BasicStyleInteractions() {
9994
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
10095
* @param onLongClick callback triggered when featureset is clicked.
10196
*/
102-
@MapboxExperimental
10397
public fun onFeaturesetLongClicked(
10498
id: String,
10599
importId: String? = null,
@@ -126,7 +120,6 @@ public class StyleInteractionsState : BasicStyleInteractions() {
126120
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
127121
* @param onLongClick callback triggered when layer is clicked.
128122
*/
129-
@MapboxExperimental
130123
public fun onLayerLongClicked(
131124
id: String,
132125
filter: Expression? = null,
@@ -143,7 +136,6 @@ public class StyleInteractionsState : BasicStyleInteractions() {
143136
*
144137
* @param onClick callback triggered when map surface is clicked.
145138
*/
146-
@MapboxExperimental
147139
public fun onMapClicked(
148140
onClick: FeaturesetFeatureScope.(InteractionContext) -> Boolean
149141
): StyleInteractionsState = apply {
@@ -157,7 +149,6 @@ public class StyleInteractionsState : BasicStyleInteractions() {
157149
*
158150
* @param onLongClick callback triggered when map surface is clicked.
159151
*/
160-
@MapboxExperimental
161152
public fun onMapLongClicked(
162153
onLongClick: FeaturesetFeatureScope.(InteractionContext) -> Boolean
163154
): StyleInteractionsState = apply {

0 commit comments

Comments
 (0)