我正在实施 Google Maps V2,我正在绘制从外部 GPX 文件、设备路径、设备当前位置和交付点位置接收的交付路线。问题是它大部分时间都有效......我得到的错误(当它不工作时)是下一个:
03-16 20:48:37.811: I/dalvikvm(16510): threadid=30: stack overflow on call to Lmaps/t/bx;.d:FLLL
03-16 20:48:37.811: I/dalvikvm(16510): method requires 40+20+0=60 bytes, fp is 0x60223318 (24 left)
03-16 20:48:37.811: I/dalvikvm(16510): expanding stack end (0x60223300 to 0x60223000)
03-16 20:48:37.811: I/dalvikvm(16510): Shrank stack (to 0x60223300, curFrame is 0x60226e54)
03-16 20:48:37.821: D/gralloc(16510): unmap_buffer: Successfully unmapped 0xa5000 bytes at address 0x60416000, SharedFd=89, map_count = 3
03-16 20:48:37.821: D/gralloc(16510): unmap_buffer: Successfully unmapped 0xa5000 bytes at address 0x604bb000, SharedFd=96, map_count = 2
03-16 20:48:37.881: W/dalvikvm(16510): threadid=30: thread exiting with uncaught exception (group=0x409f61f8)
03-16 20:32:23.471: E/AndroidRuntime(16283): FATAL EXCEPTION: GLThread 1827
03-16 20:32:23.471: E/AndroidRuntime(16283): java.lang.StackOverflowError
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.bx.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.bx.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
下面是产生问题的代码示例。
UpdateMap 方法在 Activity 的 onCreate 方法中只调用一次。UpdateMap 内部是 DrawUserLocationOnMap 调用。我愿意接受任何建议。
更新地图方法:
private void UpdateMap() {
map = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
int i = 0;
// GPS COORDINATES RECEIVED FROM GPX FILE
PolylineOptions pOptions = new PolylineOptions();
LatLng initialCameraPosition = null;
for (GpxTrackModel trackModel : ProviderUtility.GpxProvider.GpxTracks) {
for (GpxTrackCoordinateModel coorModel : trackModel.getTrackCoordinates()) {
if (i == 0)
initialCameraPosition = new LatLng(coorModel.getLatitude(), coorModel.getLongitude());
pOptions.add(new LatLng(coorModel.getLatitude(), coorModel.getLongitude()));
i++;
}
// ADDING DESTINATION MARKERS (LAST LOCATION IN TRACK SEGMENT)
MarkerOptions mOptions = new MarkerOptions();
mOptions.draggable(false);
GpxTrackCoordinateModel model = trackModel.getTrackCoordinates().get(trackModel.getTrackCoordinates().size() - 1);
mOptions.position(new LatLng(model.getLatitude(), model.getLongitude()));
mOptions.title(trackModel.getName());
map.addMarker(mOptions).showInfoWindow();
map.animateCamera(CameraUpdateFactory.newLatLngZoom(initialCameraPosition, 14));
DrawUserLocationOnMap();
}
pOptions.color(Color.parseColor("#FF0000"));
map.addPolyline(pOptions);
}
DrawUserLocationOnMap 方法:
PolylineOptions recordedPOptions = null;
MarkerOptions userLocation = null;
private void DrawUserLocationOnMap() {
// RECORDED GPS DATA WITH GREEN LINE
if (recordedPOptions == null)
recordedPOptions = new PolylineOptions();
// ADDING SAVED USER GPS COORDINATES FROM DATABASE AND DRAWING PATH
ArrayList<GPSTrackingModel> list = ProviderUtility.GPSTrackingProvider.GetGPSCoordinates(false);
for (GPSTrackingModel recordedGps : list)
recordedPOptions.add(new LatLng(Double.parseDouble(recordedGps.getLatitude()), Double.parseDouble(recordedGps.getLongitude())));
recordedPOptions.color(Color.parseColor("#00FF00"));
map.addPolyline(recordedPOptions);
// ADDING CURRENT LOCATION MARKER
GPSTrackingModel lastPosition = ProviderUtility.GPSTrackingProvider.GetLastCoordinate();
if (lastPosition != null && lastPosition.getLatitude() != null
&& !lastPosition.getLatitude().equals("")
&& lastPosition.getLongitude() != null
&& !lastPosition.getLongitude().equals("")) {
LatLng lp = new LatLng(Double.parseDouble(lastPosition.getLatitude()), Double.parseDouble(lastPosition.getLongitude()));
if (userLocation == null) {
userLocation = new MarkerOptions();
userLocation.draggable(false);
userLocation.position(lp);
userLocation.title("My current location");
userLocation.icon(BitmapDescriptorFactory.fromResource(R.drawable.currentlocation));
map.addMarker(userLocation);
} else
userLocation.position(lp);
float zoom = map.getCameraPosition().zoom;
if (zoom < 14)
zoom = 14;
map.animateCamera(CameraUpdateFactory.newLatLngZoom(lp, zoom));
}
}
更新:
为了强制出错,我添加了每 200 毫秒调用一次 DrawUserLocationOnMap() 方法的循环。4-5秒后它崩溃了。