是否有可能在谷歌地图android api上添加动画图标标记?

时间:2017-09-20 05:58:39

标签: android google-maps animation google-maps-api-3

我想添加带动画图标的标记, 但它没有用。 谷歌地图api在ios中,很简单。只需使用带有动画的imageview设置图标属性。

GMSMarker *newMarker = [GMSMarker markerWithPosition...];
newMarker.icon = animateImageView;

但在android中,使用BitMapDescriptor设置图标。 无论如何,我尝试这样,但它不起作用。 只是第一张图片显示出来。

ImageView animImgView = new ImagView(context);
//walking_person_anim.xml - <animation-list>...</animation-list> 
animImgView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.walking_person_anim));

animImgView.measure(...,...);
Bitmap markerBitmap = Bitmap.createBitmap(..., .., Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(markerBitmap);

AnimationDrawable ad = (AnimationDrawable) anim.getDrawable();
ad.setBound(0,0,...,...);
ad.draw(markerBitmap);
ad.start();

googleMap.addMarker(new MarkerOptions().position(...)
.icon(BitmapDescriptorFactory.fromBitmap(markerBitmap));

问题是什么?动画图标在Android谷歌地图中不可能?

1 个答案:

答案 0 :(得分:2)

希望您能从here.

获得更好的解决方案

在该链接上有一个关于如何在Google Maps V2上设置动画标记的问题

相关问题