android - Google Maps API 中的动画 map 标记

标签 android google-maps google-maps-markers

我正在尝试创建一个看起来像这样的自定义标记:

enter image description here

我有看起来像这样的 XML 可绘制对象:

<solid
    android:color="#0093e8"/>

<size
    android:width="120dp"
    android:height="120dp"/>

enter image description here

是否可以为标记添加“波浪效果”并且波浪逐渐淡出(如图所示)?此外,此动画应不断播放(无需用户点击 map 标记)我该怎么办?

最佳答案

我做了一些非常相似的事情,但我使用了 GroundOverlay 而不是标记,首先我定义了我的自定义动画:

public class RadiusAnimation extends Animation {
    private GroundOverlay groundOverlay;

    public RadiusAnimation(GroundOverlay groundOverlay) {
        this.groundOverlay = groundOverlay;

    }
    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        groundOverlay.setDimensions( (100 * interpolatedTime) );
        groundOverlay.setTransparency( interpolatedTime );

    }


    @Override
    public void initialize(int width, int height, int parentWidth,int parentHeight) {
        super.initialize(width, height, parentWidth, parentHeight);
    }
}

然后我在 groundOverlay 上运行动画,在 onMapReady 之后:

...
  groundOverlay = mGoogleMap.addGroundOverlay(new GroundOverlayOptions()
                    .image(image)
                    .position(new LatLng(lat, lng), 100));
  groundAnimation = new RadiusAnimation(groundOverlay);
  groundAnimation.setRepeatCount(Animation.INFINITE);
  groundAnimation.setRepeatMode(Animation.RESTART);
  groundAnimation.setDuration(2000);
  mapView.startAnimation(groundAnimation); // MapView where i show my map
...

希望对你有帮助

关于android - Google Maps API 中的动画 map 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38306777/

相关文章:

Android 谷歌地图版本 2 显示方向和谷歌地图图标

android - 谷歌地图应用程序的新更新不显示我在 Android 中创建的标记

android - 拦截 Google map 内置“我的位置”按钮的点击

android - 在 Android 中创建较小的标签

android - 带有谷歌分析的独立安卓库

android - 从 firebase 检索数据到谷歌地图

ios 谷歌地图的准确性

javascript - 如何在网站上展示 Ionic2 应用程序?

android - 从 android ContactsContract 数据库加载数据后 fragment 未填充

java - Android - 获取多段线作为图像