TradeMe / MapMe

The Android maps adapter
MIT License
841 stars 75 forks source link

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

Open hiasel opened 5 years ago

hiasel commented 5 years ago

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)