yandex / mapkit-android-demo

MapKit Android demo
Other
121 stars 59 forks source link

How to animate a marker on a map? (как сделать анимацию маркера на карте ?) #248

Closed Kooo9058 closed 3 years ago

Kooo9058 commented 3 years ago

At this point, the AnimatedImageProvider is used to animate the marker, but even in the demo project, the animation does not play. How to make an animated marker on the map?

@Override
        public void onMapLongTap(@NonNull Map map, @NonNull Point point) {
            AnimatedImageProvider provider =
                    AnimatedImageProvider.fromAsset(getApplicationContext(), "animation.png");
            IconStyle iconStyle = new IconStyle().setScale(4.f);
            mapObjects.addPlacemark(point, provider, iconStyle);
        }
eaniconer commented 3 years ago

It can be done like this:

PlacemarkMapObject placemark = mapObjects.addPlacemark(point, provider, iconStyle);
placemark.useAnimation().play();
eaniconer commented 3 years ago

The animation example in demo project seems broken because used png is not animated (not apng). Fixed in this PR: https://github.com/yandex/mapkit-android-demo/pull/250 . In addition, a new example with placemark animation has been added.

Kooo9058 commented 3 years ago

Thank you for your help. Everything works, the label is animated.