有人知道,为什么我的谷歌地图没有显示?我只能看到View,“Google”-Logo和zoom-Buttons:
map.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
MapClass:
private View view = null;
private Context context;
private MapView mapView;
private Bundle mapBundle;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mapBundle = savedInstanceState;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater
.inflate(R.layout.fragment_map, container, false);
String title = getResources().getString(R.string.MapTitle);
String subtitle = getResources().getString(R.string.MapSubtitle);
EventBus.getDefault().post(
new RefreshActionBarEvent(ActionBarType.BACK,title,subtitle));
context = view.getContext();
MapsInitializer.initialize(getActivity());
mapView = (MapView) view.findViewById(R.id.map);
mapView.onCreate(mapBundle);
GoogleMap map = ((MapView) view.findViewById(R.id.map)).getMap();
return view;
}
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
public void onDestroy() {
mapView.onDestroy();
super.onDestroy();
}
在我的Manifest.xml中:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBLS0IqFRti-R6LxbAr4X_KhkF0LWEWajg" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
我在“Logcat”中收到“无法找到com.google.android.gsf.gservices的提供商信息”作为输出。有人可以帮忙吗?谢谢:))
答案 0 :(得分:0)
这是用于显示地图的正确 Android_manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.package.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="**Replace with your key**" />
别忘了添加google-play-services_lib