大家好.......我已经成功开始Google maps android API v2
工作,但是谷歌地图使用FragmentActivity 来显示地图我想使用片段来显示当前我使用这个代码里面的地图
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try
{
setContentView(R.layout.maps);
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
Marker hamburg = map.addMarker(new MarkerOptions()
.position(HAMBURG).title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
catch (Exception e)
{
// TODO Auto-generated catch block
Log.d("Error in Maps.class = " , e.toString());
}
}
但我不想从 FragmentActivity 扩展,我想从 Fragment 扩展,即在片段内显示地图,在这方面的任何帮助都将受到高度赞赏.. 提前致谢.......