Open thomaslang1912 opened 2 years ago
@thomaslang1912 can you share the implementation of nearbyMarkers()
?
Hi Chris, to keep it simple I used the following implementation for showing the bug:
val list1 = listOf( MarkerState( LatLng(48.218967, 11.623746) ), MarkerState( LatLng(48.218967, 11.663746) ) )
val list2 = listOf( MarkerState( LatLng(48.238967, 11.623746) ), MarkerState( LatLng(48.258967, 11.623746) ) )
fun initialMarkers(): List
fun nearbyMarkers(): List
Best regards,
Thomas
hello @thomaslang1912 ,
I've had a similar issue here, that I was able to solve by using rememberMarkerState
.
Hi Carlos, using rememberMarkerState has no effect. As soon as the list of markers is changed showInfoWindow is not working anymore... @arriolac will there be a fix in future?
Hello @thomaslang1912,
I've used that approach and it worked. I don't have the project here right now, but I can attach a snippet next week.
Try Marker window info instead with MarkerState
MarkerInfoWindow(
state = MarkerState(position = position),
onClick = {
if (currentMarkerInfoWindow.position == it.position) {
it.hideInfoWindow()
currentMarkerInfoWindow.position = LatLng(0.00, 0.00)
} else {
it.showInfoWindow()
currentMarkerInfoWindow.position = it.position
}
true
},
content = {...}
What worked for me, is whenever the marker data changes on the map, just refresh the entire map. So: key(yourMarkerDataChangeTrigger) { GoogleMap(....) }
I created a map with some markers on it:
The markerStates are stored within the model in variable markerStates:
On the map I added a button. On click it iterates the marker states and shows the info window:
This works fine. Now I added a button which replaces the states in the model with new ones:
When I press this button, the new markers are displayed on the map and the first infoWindow is displayed. All following clicks on next have no effect. Always the same InfoWindow is displayed. In debug mode I saw that iteration of markerStates works correct.
Environment details
project gradle
module gradle