MapMe icon indicating copy to clipboard operation
MapMe copied to clipboard

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

Open hiasel opened this issue 6 years ago • 0 comments

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)

hiasel avatar Jun 18 '19 21:06 hiasel