2013-07-11 92 views
0

如何在Google Maps API v2上執行此操作?如何將google maps api v1的代碼轉換爲v2?

MapView mv = (MapView) findViewById(R.id.mvGoogle); 
    mv.setBuiltInZoomControls(true); 
    MapController mc = mv.getController(); 
    ArrayList all_geo_points = getDirections(17.3849, 78.4866, 28.63491, 77.22461); 
    GeoPoint moveTo = all_geo_points.get(0); 
    mc.animateTo(moveTo); 
    mc.setZoom(12); 
    mv.getOverlays().add(new MyOverlay(all_geo_points)); 

回答

1

使用FragmentActivity和onCreate()方法:

GoogleMap mMap =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); 

ArrayList <LatLng> all_geo_points = new ArrayList<LatLng>(); 

all_geo_points.add(new LatLng(17.3849, 78.4866)); 

all_geo_points.add(new LatLng(28.63491, 77.22461)); 

LatLng moveTo = all_geo_points.get(0); 

CameraPosition cameraPosition = new CameraPosition.Builder().target(moveTo).zoom(12).build(); 

mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); 

檢查地圖V2 demo

相關問題