Skip to content

Add marker animation demo - #57

Merged
wf9a5m75 merged 13 commits into
mainfrom
add-marker-demo
Sep 4, 2025
Merged

Add marker animation demo#57
wf9a5m75 merged 13 commits into
mainfrom
add-marker-demo

Conversation

@ToshiakiMasumori

Copy link
Copy Markdown
Contributor

Adding marker animation demo based on circle demo.
Also, fixing bounce animation bugs.

@ToshiakiMasumori ToshiakiMasumori self-assigned this Aug 16, 2025
@wf9a5m75

wf9a5m75 commented Aug 16, 2025

Copy link
Copy Markdown
Contributor

Thank you for your PR, it's really helpful!
One thought: if the example were a bit more meaningful, it would help developers better understand how the bounce animation works.

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!

@ToshiakiMasumori
ToshiakiMasumori requested review from KouTsukigase and wf9a5m75 and removed request for KouTsukigase and wf9a5m75 August 17, 2025 13:01
@ToshiakiMasumori

Copy link
Copy Markdown
Contributor Author

Thank you for your PR, it's really helpful! One thought: if the example were a bit more meaningful, it would help developers better understand how the bounce animation works.

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.
Just implemented the message card which shows animation list and then, if clicked it, the marker will act the animation.
Now, we just want to show demo for bounce animation. But also it became we will be able to add new ones easily.
Could you take a look again ?

@ToshiakiMasumori

Copy link
Copy Markdown
Contributor Author

@wf9a5m75

Copy link
Copy Markdown
Contributor

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)

  1. At least 3 markers (mock data is fine) with distinct names shown in a scrollable list.
  2. Tapping a list item triggers Bounce on the corresponding marker only.
  3. UI remains minimal: list on the bottom/side + map (no animation picker, no settings).

Current state

  • The current implementation has a single marker and an "Animation list" with only a Bounce button.
  • This structure is close, but for this PR we need the list to represent markers (names), not animation types.

Suggested approach

  • Define a `Spot(id, name, GeoPoint) list (3-5 items).
  • Render all markers from this list on the map.
  • On list item click: find that marker and set MarkerAnimation.Bounce.

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) }
            }
        }
    }
}

@ToshiakiMasumori

Copy link
Copy Markdown
Contributor Author

@wf9a5m75 Sorry for my late. I have just fixed them. PTAL.

# Conflicts:
#	example-app/src/main/java/com/mapconductor/example/DemoAppScreen.kt
@wf9a5m75
wf9a5m75 merged commit fbf6599 into main Sep 4, 2025
1 check failed
@wf9a5m75
wf9a5m75 deleted the add-marker-demo branch September 4, 2025 10:46
@wf9a5m75

wf9a5m75 commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

Thank you for fixing the marker animation problem. We really appreciate your help.
One thing, changing the AGP version affects other developers, especially downgrading.
I know we set version 8.9 for your environment, because version 8.10 did not work on your environment for some reasons, but please exclude the local modification for next time :)

wf9a5m75 added a commit that referenced this pull request Nov 28, 2025
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants