1
我可以建立谷歌地图的实例,并查看地图,但我不能的GetMap(),它总是空:谷歌地图是空
mMapFragment = SupportMapFragment.newInstance();
FragmentTransaction fragmentTransaction = getSupportFragmentManager()
.beginTransaction();
fragmentTransaction.replace(R.id.container, mMapFragment);
fragmentTransaction.commit();
if (mMap == null) {
mMap = mMapFragment.getMap();
// always null, why?
if (mMap != null) {
mMap.getUiSettings().setMyLocationButtonEnabled(true);
}
}
后乌尔清单 – KOTIOS
更换片段是异步的,所以这个片段可能事件不会已经放在你的布局,所以使的GetMap给你空。 您应该在此mapFragment事务结束后使用getMap方法替换/添加您的mapFragment和请求地图 –
请参阅http://stackoverflow.com/a/14909970/1051804答案 –