[go: nahoru, domu]

Skip to content
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

MarkerInfoWindow skips recomposition #46

Open
tiwiz opened this issue Feb 25, 2022 · 8 comments
Open

MarkerInfoWindow skips recomposition #46

tiwiz opened this issue Feb 25, 2022 · 8 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tiwiz
Copy link
tiwiz commented Feb 25, 2022

Environment details

  1. Maps-Compose v1.2.0

Steps to reproduce

  1. Declare a state that should be updated inside a MakerInfoWindow
  2. Update the state
  3. MakerInfoWindow will not update

Code example

@Composable
fun MapTest() {

    val empireStateBuilding = LatLng(40.7481672, -73.9859298)

    var uiSettings by remember { mutableStateOf(MapUiSettings()) }
    var properties by remember {
        mutableStateOf(
            MapProperties(mapType = MapType.SATELLITE)
        )
    }

    var downloaded by remember { mutableStateOf(false) }

    var cameraPosition = rememberCameraPositionState {
        position = CameraPosition.fromLatLngZoom(empireStateBuilding, 20f)
    }

    Box {
        GoogleMap(
            modifier = Modifier.fillMaxSize(),
            properties = properties,
            uiSettings = uiSettings,
            cameraPositionState = cameraPosition
        ) {

            MarkerInfoWindow(
                position = empireStateBuilding,
                title = "Empire State Building"
            ) {
                Card(modifier = Modifier.size(width = 200.dp, height = 200.dp)) {
                    Column(modifier = Modifier.fillMaxSize()) {
                        Text(text = it.title!!)
                        Text("Downloaded: $downloaded")
                        Box(modifier = Modifier.size(100.dp)
                        ) {
                            Image(
                                rememberImagePainter(data = "https://www.esbnyc.com/sites/default/files/a1r4P000009TJmGQAW.jpg",
                                    onExecute = { previous, current ->
                                        println("[LOG] Callback")
                                        current.state == ImagePainter.State.Empty || previous?.request != current.request
                                    }
                                ) {
                                    listener(object : ImageRequest.Listener {
                                        override fun onCancel(request: ImageRequest) {
                                            println("[LOG] onCancel")
                                        }

                                        override fun onError(
                                            request: ImageRequest,
                                            throwable: Throwable
                                        ) {
                                            println("[LOG] onError: $throwable")
                                        }

                                        override fun onStart(request: ImageRequest) {
                                            println("[LOG] onStart")
                                        }

                                        override fun onSuccess(
                                            request: ImageRequest,
                                            metadata: ImageResult.Metadata
                                        ) {
                                            println("[LOG] onSuccess")
                                            println("[LOG] downloaded: $downloaded")
                                            downloaded = true
                                            println("[LOG] downloaded: $downloaded")
                                        }
                                    })
                                },
                                contentDescription = it.title,
                            )
                        }
                    }
                }
            }
        }

        Text(
            "Downloaded: $downloaded",
            style = MaterialTheme.typography.h4,
            color = Color.Red
        )
    }
}

Sample Project attached

Screen recording of the issue

issue.mp4
@tiwiz tiwiz added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 25, 2022
@jpoehnelt
Copy link
Contributor

@tiwiz Thank you for opening this issue. 🙏
Please check out these other resources that might be applicable:

This is an automated message, feel free to ignore.

@arriolac arriolac removed the triage me I really want to be triaged. label Mar 3, 2022
@arriolac
Copy link
Member
arriolac commented Mar 3, 2022

I think this is one of the consequences from the underlying implementation of info windows which creates a bitmap of the provided View in InfoWindowAdapter and displays that instead. See my comment in https://github.com/googlemaps/android-maps-compose/blob/main/maps-compose/src/main/java/com/google/maps/android/compose/ComposeInfoWindowAdapter.kt#L15 I've logged a bug for this internally to get this addressed—the correct fix here would be to actually use the View and attach it to the window. If that were done, then recompositions would be reflected.

But, there might be a workaround here like hiding and then immediately showing the info window again on a new recomposition.

@egorikftp
Copy link

@arriolac
Hello, do you have any updates for this issue?

@ravirajcm
Copy link

Any updates or work around until it get fixed?

@joshrvezy
Copy link

looking to use compose maps, but cant until we can have the composable actually refresh cause we are loading in images by url into the MarkerInfoWindow

@joshrvezy
Copy link

any update on this? trying for the new year to finally see if we can migrate to using compose google maps, but this is the only reason why we cannot, please update would be nice

@joshrvezy
Copy link

any updates on this , were STILL looking to use compose maps but cant because of this

@khaledalsawy
Copy link

Any updates on this ?

@wangela wangela added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Nov 17, 2023
@wangela wangela assigned kikoso and unassigned arriolac Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

9 participants