我正在使用 Google Maps 的 Android 项目。
在 Google API 控制台中注册并激活(我认为是正确的)Google API V2 服务后,我尝试启动一个包含 MapView 的简单 Activity。
但是我有一个问题:当我启动我的应用程序时,地图没有出现。这是我遵循的步骤:
1.) 使用命令从我的 debug.keystore 中保留 SHA1 密钥代码
keytool.exe -list -keystore C:\Users\beef\\.android\debug.keystore
2.) 我在我的 API 控制台中输入了该密钥,并带有 SHA1 代码。
3.) 我在我的 API 控制台中激活了以下服务:“Google Maps Android API v2”和“Google Maps API v2”
4.) 我在我的 AndroidManifest.xml 和我的 layout.xml(包含 MapView)中输入了我的密钥。
5.) 我写了一些代码。
这是我的 AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testmap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="14" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
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.testmap.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>
</application>
</manifest>
这是我的 MainActivity.java :
public class MainActivity extends MapActivity {
private MapView mapView=null;
private MapController mapController=null;
private GeoPoint geoPoint=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GeoPoint gPoint = new GeoPoint(19240000,-99120000);
mapView = (MapView) findViewById(R.id.mapView);
mapView.setSatellite(true);
mapView.setBuiltInZoomControls(true);
mapController = mapView.getController();
mapController.setZoom(15);
mapController.setCenter(gPoint);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
我的 layout.xml :
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="<MyAPIKey>"/>
我读过 StackOverFlow 的帖子,没有显示地图(仅显示网格)是正常的。但我想有一个明确的答案。
我也尝试导出为已签名的应用程序并将其安装在我的 Android 手机上,结果相同。
也许它可以帮助你,当我在我的应用程序上时,我的 logcat 中有一个错误:
01-17 12:27:41.394: W/System.err(801): IOException processing: 26
01-17 12:27:41.404: W/System.err(801): java.io.IOException: Server returned: 3
01-17 12:27:41.404: W/System.err(801): at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
如果有人可以帮助我,
谢谢,
牛肉