Trying to reason through some behavior I just obse...
# compose
t
Trying to reason through some behavior I just observed. I'm trying to "draw above" a map. Structurally, I have: Box rememberCameraPositionState() Map.fullSize Canvas.fullSize When I do this:
Copy code
Canvas(modifier = Modifier.fillMaxSize()) {
   cameraPositionState.projection?.let { projection -> 
       /* draw stuff based on projection */ }}
things work fine. But if switch those around:
Copy code
cameraPositionState.projection?.let { projection ->
    Canvas(modifier = Modifier.fillMaxSize()) {
       /* draw stuff based on projection */ }}
then it does an initial draw, but even if it updates, uses the original projection. IIUC, in the first one, the draw scope, upon reading/accessing the cameraPositionState creates a dependency that causes the Canvas to recompose when the state changes. So it works. But in the second case, I would have thought that same thing would have happened at the Box level. A change in cameraState would cause it to reissue the Canvas composable. But that doesn't seem to happen. There's a puzzle piece that doesn't fit yet for me.
c
Are you using AndroidView with google map, or the new google-maps-compose artifact? (which internally is an androidView anyway). but yeah. just curious.
t
I'm using the Compose Maps (the newer one). I'm all about "Only New Stuff if Possible" in this journey. 😄 No left over half finished baggage. Just the new half finished stuff.