Skip to content

Custom animations (scale, rotate, translate) do not work? #33

@hiasel

Description

@hiasel

I would like to add a custom animation when markers are attached to the adapter. Following the provided sample code from the README, the alpha animation works perfectly on my created markers (https://github.com/TradeMe/MapMe#animations):

override fun onAnnotationAdded(annotation: MapAnnotation) {
        if (annotation !is MarkerAnnotation) return

        ObjectAnimator.ofFloat(annotation, "alpha", 0f, 1f)
                .apply {
                    duration = 150
                    interpolator = DecelerateInterpolator()
                    start()
               }
}

However, when I try to implement a different animation, it doesn't seem to work, i.e. the markers simply pop up without any animation?
I've tried translation, rotationand scale as follows:

ObjectAnimator.ofFloat(annotation, "translationX", 100f).apply {
    duration = 1000
    start()
}
ObjectAnimator.ofFloat(annotation, "rotation", 360f).apply {
    duration = 1000
    start()
}
ObjectAnimator.ofFloat(annotation, "scaleX", 2f).apply {
    duration = 1000
    start()
}

Am I doing something wrong or is alpha the only supported animation on markers?
Btw.: I am using the default google maps marker icon, i.e.:

factory.createMarker(LatLng(item.lat, item.lon), null, item.title)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions