我正在开发一个使用谷歌地图的Android应用程序。我想在MapView中显示带有一些坐标的叠加图像。我需要为图像设置动画。请帮忙。我的代码如下
mapView = (MapView) findViewById(R.id.myGMap);
mapView.setBuiltInZoomControls(true);
mapController = mapView.getController();
mapView.buildDrawingCache();
mapView.setAnimationCacheEnabled(true);
mapView.setClickable(true);
mapView.getZoomLevel();
mapView.displayZoomControls(true);
mapView.getMapCenter();
List<Overlay> mapOverlays = mapView.getOverlays();
drawable = getResources().getDrawable(R.drawable.img1);
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);
int latitudeE6 = (int)((12.907382) * 1000000);
int longitudeE6 = (int)((77.595105) * 1000000);
point = new GeoPoint(latitudeE6,longitudeE6);
overlayitem = new OverlayItem(point, "", "");
mapController.animateTo(point);
itemizedoverlay.addOverlay(overlayitem);
itemizedoverlay.getCenter();
itemizedoverlay.getFocus();
mapOverlays.add(itemizedoverlay);
答案 0 :(得分:3)
public static void addAnimationToMap(MapView map, int animationResourceId, GeoPoint geoPoint)
{
final ImageView view = new ImageView(map.getContext());
view.setImageResource(animationResourceId);
//Post to start animation because it doesn't start if start() method is called in activity OnCreate method.
view.post(new Runnable() {
@Override
public void run() {
AnimationDrawable animationDrawable = (AnimationDrawable) view.getDrawable();
animationDrawable.start();
}
});
map.addView(view);
MapView.LayoutParams layoutParams = new MapView.LayoutParams(
MapView.LayoutParams.WRAP_CONTENT,
MapView.LayoutParams.WRAP_CONTENT,
geoPoint,
MapView.LayoutParams.BOTTOM_CENTER);
view.setLayoutParams(layoutParams);
}
您可以在res-&gt; drawable中添加动画列表,并将drawable传递给此函数。 AFAIK是在谷歌地图上添加动画标记的唯一可能方法是在地图上方添加视图
答案 1 :(得分:0)
我认为这很难做,但您可以使用drawable中的alpha功能创建alpha动画,如下所示:
drawable.setAlpha();