2017-05-23 118 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); 
}