首先,我的问题与各种与API密钥相关的MapView磁贴问题不同,它也与this question或that one不匹配,尽管它确实有相似之处。
有时候我会遇到一些瓷砖无法加载,在Android MapView上留下空白的灰色斑点 LogCat显示了这个:
05-15 11:55:01.178: W/System.err(11978): IOException processing: 26
05-15 11:55:01.178: W/System.err(11978): java.io.EOFException
05-15 11:55:01.178: W/System.err(11978): at java.io.DataInputStream.readFully(DataInputStream.java:267)
05-15 11:55:01.178: W/System.err(11978): at java.io.DataInputStream.readFully(DataInputStream.java:212)
05-15 11:55:01.178: W/System.err(11978): at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readImageData(BaseTileRequest.java:194)
05-15 11:55:01.178: W/System.err(11978): at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:124)
05-15 11:55:01.178: W/System.err(11978): at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
05-15 11:55:01.178: W/System.err(11978): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
05-15 11:55:01.178: W/System.err(11978): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
05-15 11:55:01.178: W/System.err(11978): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
05-15 11:55:01.188: W/System.err(11978): at java.lang.Thread.run(Thread.java:1027)
当您在地图上移动和缩放时旋转设备时,可以在仅包含MapView的准系统应用程序中重现这一点。但这并不是一直发生的。也许存在某种竞争条件。
package my.TestApp;
import com.google.android.maps.*;
import android.os.Bundle;
public class MainActivity extends MapActivity {
MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="MyApiKeyGoesHere"
/>
</RelativeLayout>