Environment
|
|
| Mapbox Maps Android |
com.mapbox.extension:maps-compose-ndk27:11.23.0 |
| Kotlin |
2.3.21 (K2) |
| Compose plugin |
org.jetbrains.kotlin.plugin.compose 2.3.21 |
| Android Gradle Plugin |
9.2.0 |
| Compose BOM |
2026.04.01 |
Reproduction
MapboxMap(
style = {
MapStyle(
style = """{"version": 8}""",
styleState = rememberStyleState(),
)
},
) {
BackgroundLayer { backgroundColor = ColorValue(Color.White) }
DisposableMapEffect(Unit) { _ -> onDispose {} }
}
Observed warnings
At MapStyle(...) inside style = { ... }:
Calling a Mapbox Style Composable composable function where a UI Composable
composable was expected
At BackgroundLayer { ... } and DisposableMapEffect(...) inside the trailing
content lambda:
Calling a Mapbox Map Composable composable function where a Mapbox Style
Composable composable was expected
The markers appear shifted by one slot: style is inferred as plain UI, while
content is inferred as @MapboxStyleComposable. Slot placement matches the
documented signature in MapboxMap.kt:
style: @Composable @MapboxStyleComposable () -> Unit = { MapboxStandardStyle() },
content: (@Composable @MapboxMapComposable MapboxMapScope.() -> Unit)? = null
Why this is new
Kotlin 2.2.20 enabled @ComposableTarget enforcement on K2 (release
notes). These warnings were silent
before — any latent issue with the marker annotations on MapboxMap's slots only
surfaces now.
This is the same class of false positive that googlemaps/android-maps-compose hit
in #598 and
resolved library-side via PR #763.
Related: ViewAnnotation
The content slot of ViewAnnotation is annotated @MapboxMapComposable, but its
purpose is to host plain UI. Calling Box/Text inside produces the inverse
warning:
Calling a UI Composable composable function where a Mapbox Map Composable
composable was expected
Likely fix
Annotation placement on the slot lambdas in MapboxMap.kt and ViewAnnotation.kt.
The style and content markers in MapboxMap may need different declaration
ordering, and ViewAnnotation's content slot should probably drop
@MapboxMapComposable.
Workaround (consumer side)
@Suppress(
"COMPOSE_APPLIER_CALL_MISMATCH",
"COMPOSE_APPLIER_PARAMETER_MISMATCH",
"COMPOSE_APPLIER_DECLARATION_MISMATCH",
)
@Composable
fun MyMapScreen() { ... }
Environment
com.mapbox.extension:maps-compose-ndk27:11.23.0org.jetbrains.kotlin.plugin.compose2.3.21Reproduction
Observed warnings
At
MapStyle(...)insidestyle = { ... }:At
BackgroundLayer { ... }andDisposableMapEffect(...)inside the trailingcontent lambda:
The markers appear shifted by one slot:
styleis inferred as plain UI, whilecontentis inferred as@MapboxStyleComposable. Slot placement matches thedocumented signature in
MapboxMap.kt:Why this is new
Kotlin 2.2.20 enabled
@ComposableTargetenforcement on K2 (releasenotes). These warnings were silent
before — any latent issue with the marker annotations on
MapboxMap's slots onlysurfaces now.
This is the same class of false positive that
googlemaps/android-maps-composehitin #598 and
resolved library-side via PR #763.
Related:
ViewAnnotationThe content slot of
ViewAnnotationis annotated@MapboxMapComposable, but itspurpose is to host plain UI. Calling
Box/Textinside produces the inversewarning:
Likely fix
Annotation placement on the slot lambdas in
MapboxMap.ktandViewAnnotation.kt.The
styleandcontentmarkers inMapboxMapmay need different declarationordering, and
ViewAnnotation's content slot should probably drop@MapboxMapComposable.Workaround (consumer side)
@Suppress( "COMPOSE_APPLIER_CALL_MISMATCH", "COMPOSE_APPLIER_PARAMETER_MISMATCH", "COMPOSE_APPLIER_DECLARATION_MISMATCH", ) @Composable fun MyMapScreen() { ... }