Add marker animation demo - #57
Conversation
|
Thank you for your PR, it's really helpful! For example, you could place some markers on the map and display a list of them. Then, when a list item is tapped, the corresponding marker could bounce. It would be great if you could create a more illustrative example like this. Thanks for your cooperation! |
Thank you for comment. I believe that's great idea. |
|
Thanks a lot for the bug fix and the demo work - really appreciated! I might have been unclear earlier, so let me restate the exact behavior we need for this demo: Place multiple markers (e.g., cities or sightseeing spots, etc) on the maps, show a list of their names, and when a list item is tapped, the corresponding marker bounces. (As mentioned earlier) Acceptance criteria (minimal)
Current state
Suggested approach
Thanks again for the quick iteration! P.S. I know you're still new to Jetpack Compose, but given your strong coding skills, I'm confident you can pull this off smoothly. 💪 Snippet: // 1) Spot data
data class Spot(val id: String, val name: String, val point: GeoPoint)
val spots = listOf(
Spot("s1", "Honolulu", GeoPoint.fromLatLong(21.3069, -157.8583)),
Spot("s2", "Waikiki Beach", GeoPoint.fromLatLong(21.2766, -157.8289)),
Spot("s3", "Pearl Harbor", GeoPoint.fromLatLong(21.3649, -157.9491)),
)
// 2) ViewModel example
class AnimationPageViewModelImpl : ViewModel(), AnimationPageViewModel {
... // Omitting other implementations
private val markers: Map<String, MarkerState> = spots.associate { spot ->
spot.id to MarkerState(
id = "marker_${spot.id}",
position = spot.point,
icon = DefaultIcon(label = spot.name.first().uppercase()),
animation = null
)
}
fun onSpotTapped(spotId: String) {
markers[spotId]?.let { m ->
m.animation = MarkerAnimation.Bounce
}
}
val allMarkers: Collection<MarkerState> get() = markers.values
}
// 3) Map (Place multiple markers)
@Composable
fun AnimationMapComponent(..., viewModel: AnimationPageViewModelImpl) {
MapViewContainer(...) {
viewModel.allMarkers.forEach { marker ->
key(marker.id) { Marker(marker) }
}
}
}
// 4) UI ("Animation list"→"Spot list")
@Composable
fun SpotList(viewModel: AnimationPageViewModelImpl, paddingValues: PaddingValues) {
MessageCard(
modifier = Modifier
.align(Alignment.BottomStart)
.padding(bottom = paddingValues.calculateBottomPadding() + 16.dp),
title = "Spots"
) {
LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp)) {
items(spots) { spot ->
Button(
modifier = Modifier.fillMaxWidth(),
onClick = { viewModel.onSpotTapped(spot.id) }
) { Text(spot.name) }
}
}
}
} |
|
@wf9a5m75 Sorry for my late. I have just fixed them. PTAL. |
# Conflicts: # example-app/src/main/java/com/mapconductor/example/DemoAppScreen.kt
|
Thank you for fixing the marker animation problem. We really appreciate your help. |
* change agp version to build * Add animation map component * add animation demo route * fix bounce logic * change icon * remove circle * Refactor: create list of animation and remove unnecessary lines. * fix: animation list * refactor: columns * set gradle version 8.10.1 * fix: linter errors --------- Co-authored-by: Masumori <masumori.toshiaki@sysmex.co.jp> Co-authored-by: Masashi Katsumata <wf9a5m75@gmail.com>
Adding marker animation demo based on circle demo.
Also, fixing bounce animation bugs.