Android设备仅显示地图瓦片。这似乎是一个普遍的问题。我按照此链接的说明操作:
https://developers.google.com/maps/documentation/android/start
我做了以下事情:
1) 在Eclipse中,我以发布模式登录。我选择“文件”>“导出”。选择“导出Android应用程序”,然后单击“下一步”。创建一个新的密钥库。然后上传apk到Google Play。
2) Android应用程序在设备上运行,但地图没有显示。它只显示了瓦片。
3) 因此,我按照上面链接中的说明进行操作。
4) 我找到了我上面创建的密钥库文件。我的密钥库名为ziggy.keystore,别名为ziggy keystore。
5) 我在Mac OSX终端中运行了以下命令:
keytool -list -v -keystore ziggy.keystore -alias ziggy\ keystroke
6) 以上命令产生的输出包括一个包含证书SHA-1指纹的行。指纹是由冒号分隔的20个两位十六进制数字序列。
7) 现在我有了签名证书的指纹,我在Google APIs控制台中为应用程序创建了一个项目。在浏览器中,我导航到https://code.google.com/apis/console/
8) 我点击“创建项目”。我将其命名为API项目。在主窗口中,我看到了一系列API和服务。
9) 我向下滚动,直到看到Google Maps Android API v2。在条目右侧,我点击开关指示器,以使其打开。我同意服务条款并点击接受。
10) 在左侧导航栏中,我点击API访问。在生成的页面中,我点击“创建新的Android密钥”。在生成的对话框中,我输入SHA-1指纹,然后是应用程序的包名称。
11) 我复制了API密钥。我打开了应用程序的清单,包含在文件AndroidManifest.xml中。并将以下元素作为元素的子元素添加,通过在关闭标记之前插入它:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_api_key"/>
* 注意,我使用的是真实的 API 密钥。
12)我也添加了这个:
<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"/>
<permission
android:name="com.otl.AndroidRemoteApp1.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.otl.AndroidRemoteApp1.permission.MAPS_RECEIVE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
13) 接着在我的ShowMapActivity.java文件中:
super.onCreate(savedInstanceState);
setContentView(R.layout.show_map);
mapView = (MapView) findViewById(R.id.mapview);
myMapController = mapView.getController();
mapView.setBuiltInZoomControls(true);
Drawable marker=getResources().getDrawable(android.R.drawable.star_big_on);
...
14) 然后在我的show_map.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:state_enabled="true"
android:apiKey="my_api_key"
/>
* 我用真实的密钥替换了my_api_key。
我按照所有说明进行操作,但是当我在安卓设备上下载应用程序时,它没有显示地图。它只显示了瓦片内容,这已经有人报告过了。
我不确定我错过了哪一步才能使其正常工作。