2

我正在開發一個使用google地圖的android應用程序。我想在MapView中顯示帶有一些座標的疊加圖像。我需要爲圖像製作動畫。請幫忙。我的代碼如下如何在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

我正在努力解決這個問題,請大家幫忙。 – stanley

回答

0

我相信這是做辛苦的事情,但你可以使用Alpha功能從繪製創建奧飛動漫如下:

drawable.setAlpha(); 
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-> drawable中添加動畫列表,並將drawable傳遞給這個函數。 AFAIK在谷歌地圖上添加動畫標記的唯一可能方式是在地圖上方添加視圖