繁体   English   中英

GoogleMaps API 中的动画地图标记

[英]Animate map Marker in GoogleMaps API

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

在此处输入图片说明

我有 XML 中的 drawable,看起来像这样:

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

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

在此处输入图片说明

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

我做了一些非常相似的事情,但我使用了 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);
    }
}

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

...
  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
...

我希望这可以帮助你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM