I have the following marker that is added successfully on a Google Map:
Marker(
state = MarkerState(
position = LatLng(lat, lng)
),
title = "Party",
snippet = "Come to party.",
draggable = true
)
I set this marker to be draggable and it works, but how to know the new coordinated when the marker is dropped?
I think this can be done by remembering the marker state you are passing to the Marker
; for instance, you can write the following code and query the state for the new coordinates or pass that state to where you want to get the updates:
val markerState = rememberMarkerState(position = LatLng(lat, lng))
Marker(
state = markerState
title = "Party",
snippet = "Come to party.",
draggable = true
)
That way, on every recomposition, upon dragging the marker, the new position will be in the markerState
.
I hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With