【发布时间】:2014-07-23 08:18:13
【问题描述】:
I am trying google map v2 in tabhost but google map unable to display properly that only showing gray grids, I have extended activity as fragment activity. I tried lots of solution to resolve this problem but nothing helps to me, other things are working properly, even if i open map in separate activity then i can able to do anything with the maps,Please help me to resolve this issue,Thanks in advance.
My code is:
<RelativeLayout
android:id="@+id/layMapFragment"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="50" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
</LinearLayout>
以下是我使用谷歌地图的方法,我不明白为什么地图不能在 tabhost 中工作,即使我已将相同的活动扩展为片段活动
public void declareView() {
mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
mMap.setMyLocationEnabled(true);
mMap.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng arg0) {
}
});
}
}
【问题讨论】:
-
发布快照...!!!
-
大家好,我通过添加以下代码解决了我的问题: FragmentManager myFM = getSupportFragmentManager(); SupportMapFragment myMAPF = (SupportMapFragment) myFM .findFragmentById(R.id.map); myMAPF.onResume(); mMap = myMAPF.getMap(); mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); mMap.setMyLocationEnabled(true);
标签: android google-maps android-tabhost supportmapfragment