Polyline doesn't recompose when points change
See original GitHub issueEnvironment details
Android API 26 com.google.maps.android:maps-compose:2.1.0
Steps to reproduce
- Create a map with a MutableStateList of points
- Use the points to draw markers and a polyline between them
- Add functionality to add or remove points from the list
- Observe that the markers update, but the polyline does not
Code example
@Composable
fun MapScreen(){
val waypoints = remember{ mutableStateListOf<LatLng>()}
Map(waypoints) {
waypoints.add(it)
}
}
@Composable
private fun Map(
waypoints: List<LatLng>,
modifier: Modifier = Modifier,
onMapClicked: (latlng: LatLng) -> Unit
){
GoogleMap(
modifier = modifier,
onMapClick = onMapClicked,
){
waypoints.forEach {
Marker(state = MarkerState(position = it))
}
Polyline(waypoints)
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Why does the Composable for the route recompose when ...
I was thinking that it only changed the Composable where the State ... that contains (reads) State will recompose when the State changes....
Read more >Visible Polygon Vertices - Troubleshooting
I think I'm just repeating what Andy Broomell suggested. -after decomposing the polyline change the start/stop end conditions to a point. A ...
Read more >Gathering points defining 3D AutoCAD geometry using .NET
Here's the updated C# code – the main changes are at the beginning of the CollectPoints() function, where I've added the handling of...
Read more >[Solved]-Google maps won't recompose Android-kotlin
You need to provide an update callback.The AndroidView recomposes whenever a State read within the callback changes. @Composable fun CustomView() { val ...
Read more >copy and mirror polyline in vbscript?
1. at each start point of the line, mirror a copy from its start point ... movements of the system as the internal...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe the issue might be between the interaction of
mutableStateListOf
and aComposeNode
’sUpdater
. BecausePolyline
as currently implemented should work. I’ve opened an issue in the public issue tracker for Compose here: https://issuetracker.google.com/issues/232271525Is the question still open? Help me. the last Polyline is not updated, but markers are drawn according to the route.