googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.15k stars 135 forks source link

Aync Image loading (Coil) is not working (Loader being cancelled) #542

Open cwsiteplan opened 6 months ago

cwsiteplan commented 6 months ago

Re-opening an issue here as this is still not resolved #385 Please provide any feedback - this is a blocker for us.

pioPirrung commented 6 months ago

PR #538 seems to fix the cancellation issue. At least for me. I hope this helps

cwsiteplan commented 6 months ago

thanks for the pointer - hopefully that gets merged soon!

pioPirrung commented 6 months ago

I hope so, this is blocking me too... I already asked at the PR if there's an update. So lets see how long this takes :shipit:

cwsiteplan commented 5 months ago

i applied the fix from the PR locally - but works not all the time :/

pioPirrung commented 5 months ago

Are you using clustering? Because I do and it works every time. Even when fresh installing the application where the images are not cached yet and need to be fetched first

cwsiteplan commented 5 months ago

@pioPirrung just tried to replicate in the sample app and it's true - working fine now when using clusters - but using a simple MarkerComposable() it's still not loading (loader being cancelled)

i reproduced it here in the sample app (BasicMapActivity) https://github.com/cwsiteplan/android-maps-compose/pull/1

pioPirrung commented 5 months ago

PR #538 got merged and is available in version 4.4.1 FYI. Initially I thought the PR would fix both, but yes this isn't the case. Only fixes it for Clustering and MarkerComposable is still broke and needs to be fixed in another PR

jialbanc commented 4 months ago

Having same issue, any updates on resolving these??

duranaustin commented 4 months ago

Seeing this issue as well for MarkerComposable. Trying to load a Coil AsyncImage as a map Marker.

jialbanc commented 3 months ago

Any news on fixing this issue?? Please tell us about any updates

AnaMaria-Birligea commented 3 months ago

Same issue...

ArleyPereira commented 2 months ago

Same issue...

squeezymo commented 2 months ago

Same issue.

As a workaround, I'm hoisting marker ID and using it as a key to compose both a painter and a MarkerComposable. Otherwise images get messed up when the map recomposes.

key(markerId) {
    val painter = rememberAsyncImagePainter(
        ImageRequest.Builder(LocalContext.current)
            .data("https://...")
            .allowHardware(false)
            .build()
    )

    MarkerComposable(
        keys = arrayOf(painter.state),
        state = rememberMarkerState(position = LatLng(lat, lng)),
    ) {
        Image(
            painter = painter,
            contentDescription = null,
        )
    }
}
AnaMaria-Birligea commented 2 months ago

Same issue.

As a workaround, I'm hoisting marker ID and using it as a key to compose both a painter and a MarkerComposable. Otherwise images get messed up when the map recomposes.

key(markerId) {
    val painter = rememberAsyncImagePainter(
        ImageRequest.Builder(LocalContext.current)
            .data("https://...")
            .allowHardware(false)
            .build()
    )

    MarkerComposable(
        keys = arrayOf(painter.state),
        state = rememberMarkerState(position = LatLng(lat, lng)),
    ) {
        Image(
            painter = painter,
            contentDescription = null,
        )
    }
}

It works with this workaround. Thank you!

But we are still waiting for the fix in the library...