Skip to content

Android MarkerInfoWindow custom content is not rendered in Compose Multiplatform #19

Description

@HysonHou

Summary

MarkerInfoWindow custom composable content works on iOS but does not appear on Android.

On Android, tapping the marker produces no visible info window. The marker is clickable, but neither the custom content nor the title / snippet fallback is shown.

Version

eu.buney.maps:kmp-maps-compose:0.6.1

Reproduction

MarkerInfoWindow(
    state = rememberUpdatedMarkerState(position = newYork),
    title = "New York",
    snippet = "The Big Apple",
    onInfoWindowClick = { marker ->
        logger.i("Custom info window clicked: ${marker.title}")
    },
) {
    CustomInfoWindow(
        title = "New York City",
        subtitle = "The Big Apple",
        description = "Population: 8.3M",
    )
}

Expected behavior

Tapping the marker should show the custom CustomInfoWindow content on both Android and iOS.

If custom content cannot be rendered, the marker should at least display the default title/snippet info window.

Actual behavior

  • iOS: the custom info window is displayed.
  • Android: tapping the marker does not display any info window.

Replacing MarkerInfoWindow with a standard Marker using the same title and snippet displays the default Android info window correctly.

Suspected cause

The Android implementation delegates to Google Maps Compose:

AndroidMarkerInfoWindow(
    // ...
    content = content?.let { contentLambda ->
        { googleMarker -> contentLambda(Marker(googleMarker)) }
    },
)

However, Google Maps Compose declares this parameter as:

content: (@UiComposable @Composable (Marker) -> Unit)?

while kmp-maps-compose currently declares and forwards it as:

content: (@Composable (Marker) -> Unit)?

The missing @UiComposable annotation may cause the custom content to be composed in the wrong context on Android. It also explains why the title/snippet fallback is not shown: Android receives a non-null custom-content callback but renders an empty result.

Relevant files:

  • kmp-maps-compose/src/commonMain/kotlin/eu/buney/maps/Marker.kt
  • kmp-maps-compose/src/androidMain/kotlin/eu/buney/maps/Marker.android.kt

Could you please confirm whether @UiComposable should be propagated through the public expect/actual APIs and the Android delegate lambda?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions