2017-05-23 158 views
0

我在Android上學習Google Maps API,我剛剛學會了如何做到這一點。在Google地圖中縮放動畫

@Override 
public void onMapReady(GoogleMap googleMap) { 
    mMap = googleMap; 

    mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); 
    // Add a marker in Uman and move the camera 
    LatLng uman = new LatLng(48.754683, 30.216339); 
    mMap.addMarker(new MarkerOptions().position(uman).title("Home Town")); 
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(uman, 10)); 
} 

但不是地圖上直接加載到標記,我希望它加載完全縮小,然後放大到標記在動畫...

真的希望是有道理.. 。

回答

2

做到這一點,而不是mMap.moveCamera(..)

@Override 
public void onMapReady(GoogleMap googleMap) { 
    mMap = googleMap; 

    mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); 
    // Add a marker in Uman and move the camera 
    LatLng uman = new LatLng(48.754683, 30.216339); 
    mMap.addMarker(new MarkerOptions().position(uman).title("Home Town")); 
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(uman, 10)); 
} 
+0

這不會縮放動畫 – Eddie

0

試試這個....

@Override 
public void onMapReady(GoogleMap googleMap) { 
    mMap = googleMap; 

    mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); 
    // Add a marker in Uman and move the camera 
    LatLng uman = new LatLng(48.754683, 30.216339); 
    mMap.addMarker(new MarkerOptions().position(uman).title("Home Town")); 
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(uman, 10)); 
    Handler handler = new Handler(); 
    handler.postDelayed(new Runnable() { 
     public void run() {      
      mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(uman, 16)); 
     } 
    }, 1000); 
}