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 evend工作,我已经扩展为片段活动
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) {
}
});
}
}
答案 0 :(得分:0)
很可能您还没有获取Google Maps API密钥。如果不这样做,则会阻止显示地图。有关如何访问此页面的说明:
https://developers.google.com/maps/documentation/android/#apikey
答案 1 :(得分:0)
你确定地图显示在普通片段中吗?
我的意思是你先尝试在没有tabhost的情况下显示地图吗?确保地图工作正常?