8

ルートに属するポイントのリストを使用してMapView(新しいAPI v2)を使用します。彼らはかなり近いです。私の問題は私がしなければアニメーションのステップはマップビューでカメラパスをスムーズにアニメーション化する

 mMapInstance.animateCamera(CameraUpdateFactory.newLatLng(mNextPosition),ms, null); 

カメラマンは勇敢なバッタのように振る舞い、そして出てパンやexaggeratelyでの呼び出し、および、あるプロセスのAlスライドキャッシュは@ ## @#@#取得します!

パスをアニメーション化して一様なスクロールエクスペリエンスを得るための最良の方法は何ですか?スピードは問題ではない、私は低速を使用するだろう、私は滑らかさに興味がある...

私は指で行うパスをシミュレートすることができれば幸せ以上になります..マップは美しく動作するためキャッシュされた周りにたくさんのタイルがあります。しかし、プログラムでマップを移動しようとすると、大胆なアニメーション、白いスクリーン、タイルのリロードが発生します。

ありがとうございます!!!

答えて

1

誰かがより良い答えを提供したいと思っていますが、私がやった多くの実験では、animateCameraを使ってうまくスムーズにスクロールすることができませんでした。

カメラマンは、近くにあるポイントのLat/Lngを変更するだけで、印象的な離陸と着陸を続けました。その後、ランダムに高架道路のアニメーションを作る、

private void animateTo(double lat, double lon, double zoom, double bearing, double tilt, final int milliseconds) { 

     if (mMapInstance==null) return; 
     mMapInstance.setMapType(paramMapMode); 
     mCurrentPosition=new LatLng(lat,lon); 

     // animate camera jumps too much 
     // so we set the camera instantly to the next point 

     mMapInstance.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(mCurrentPosition,(float)zoom, (float)tilt, (float)bearing))); 

     // give Android a break so it can load tiles. If I start the animation 
     // without pause, no tile loading is done 

     mMap.postDelayed(new Runnable(){ 
      @Override 
      public void run() { 
       // keeping numbers small you get a nice scrolling effect 
       mMapInstance.animateCamera(CameraUpdateFactory.scrollBy(250-(float)Math.random()*500-250, 250-(float)Math.random()*500),milliseconds,null); 

      }},500); 

    } 

このルーチンは、10,000秒でミリ秒の値と呼ばれる一点に行く:私は以下のルーチンで制限された「エル安っぽい」アニメーションの成功を収めている

ジムズームトランキロを維持する方向。ピクセル値が非常に小さいので、チャンスは すべてキャッシュされています。

誰かがより良い解決策をお持ちですか?触れられた逃げをシミュレートするためにタッチイベントを注入しようとすることは妥当か可能か?

+4

あなたはMMAPに 'postDelayedを()'を呼び出すことはできません! –

4

私は、オプションのコールバックを最終的なパラメータとして使用すると、再帰的なソリューションをマニフェストすると滑らかなアニメーションが得られることが分かりました。このコードはズームインし、パノラマ式スピンの角度を変更してから再びズームインします。最初のパラメータと最初のコールバックが同じ場合は、それは好きではありません。私は、再帰を呼び出すには良い方法があります確信している、うまくいけば、これはあなたが機能的にアニメーション化する方法のアイデアを与えることができます。

//initial zoom 
static final int initZoom = 8; 
//steps the zoom 
int stepZoom = 0; 
// number of steps in zoom, be careful with this number! 
int stepZoomMax = 5; 
//number of .zoom steps in a step 
int stepZoomDetent = (18 - initZoom)/stepZoomMax; 
//when topause zoom for spin 
int stepToSpin = 4; 
//steps the spin 
int stepSpin = 0; 
//number of steps in spin (factor of 360) 
int stepSpinMax = 4; 
//number of degrees in stepSpin 
int stepSpinDetent = 360/stepSpinMax; 

Intent detailIntent; 
Intent intent; 
Marker marker; 
final int mapHopDelay = 2000; 

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.map_affirm); 
    try 
    {MapsInitializer.initialize(this);} 
    catch (GooglePlayServicesNotAvailableException impossible) 
    { /* Impossible */ Log.e(TAG, "the impossible occurred");} 
    intent = this.getIntent(); 
    latLng = new LatLng(intent.getDoubleExtra("Latitude", 0.0), intent.getDoubleExtra("Longitude", 0.0)); 
    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); 
    map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() 
                  .target(latLng) 
                  .zoom(initZoom-1) 
                  .build()) 
         , mapHopDelay 
         , cameraAnimation 
        ); 
    marker = map.addMarker(new MarkerOptions() 
          .draggable(true) 
          .position(latLng) 
          .title("Location of Photographer")); 

} 

public CancelableCallback cameraAnimation = new CancelableCallback(){ 

    @Override 
    public void onFinish() 
    { 
     if (stepZoom < stepZoomMax && stepZoom != stepToSpin) 
     { 
      stepZoom++; 
      map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() 
                    .target(latLng) 
                    .zoom(initZoom + (stepZoomDetent * (stepZoom - 1))) 
                    // .bearing(40*aniStep) 
                    // .tilt(60) 
                    .build()), mapHopDelay, cameraAnimation); 

     } 
     else if (stepZoom >= stepZoomMax)// ending position hard coded for this application 
     {map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() 
                   .target(latLng) 
                   .zoom(18) 
                   // .bearing(0) 
                   .tilt(0) 
                   .build())); 
     } 
     else 
     { 
      if (stepSpin <= stepSpinMax) 
      { 
       stepSpin++; 
       map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() 
                     .target(latLng) 
                     .zoom(initZoom + stepZoomDetent * stepZoom) 
                     .bearing(stepSpinDetent * (stepSpin - 1)) 
                     .tilt(60) 
                     .build()), mapHopDelay, cameraAnimation); 
      } 
      else 
      { 
       stepZoom++; 
       map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() 
                     .target(latLng) 
                     .zoom(initZoom + stepZoomDetent * stepZoom) 
                     .bearing(0) 
                     .tilt(0) 
                     .build()), mapHopDelay, cameraAnimation); 
      } 
     } 
    } 

    @Override 
    public void onCancel() 
    {} 

}; 
+1

こんにちは!面白いと思う、私はコールバックを使用していない、試してみるつもりだ。コードを投稿していただきありがとうございます! – rupps

関連する問題