我正在开发一个应用程序,我在其中尝试使用 Mapforge 获取离线地图数据。我成功集成到系统中。我已经检测到更改列表器上的缩放级别,并且基于我需要设置标记的级别。所以我只写了简单的代码那 ...
@Override
public void onZoomLevelChanged(int zoomLevel) {
// TODO Auto-generated method stub
Log.i("TAG","Zoom Level has change");
int intZoom = mapView.getMapPosition().getZoomLevel();
if(intZoom <4)
{
if(!mapView.getOverlays().isEmpty())
{
mapView.getOverlays().clear();
mapView.invalidate();
mapView.getOverlays().remove(mapOverlays);
mapView.invalidate();
isFirstTimeExecution = false;
}
}
else if( intZoom >4 && intZoom < 15)
{
if(mapView.getOverlays().isEmpty() && !isFirstTimeExecution)
{
mapView.getOverlays().add(mapOverlays);
mapView.invalidate();
isFirstTimeExecution = true;
}
}
}
//这里基本上我想在缩放级别 4 到 15 中设置标记,如果缩放级别应该小于 4,那么它将删除或隐藏,但是这里抛出一些线程异常,不知道为什么会引发
错误 ::
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): FATAL EXCEPTION: main
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): java.lang.IllegalThreadStateException: Thread already started.
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at java.lang.Thread.start(Thread.java:1322)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at org.mapsforge.android.maps.overlay.OverlayList.setupOverlay(OverlayList.java:193)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at org.mapsforge.android.maps.overlay.OverlayList.add(OverlayList.java:53)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at org.mapsforge.android.maps.overlay.OverlayList.add(OverlayList.java:30)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at com.offlinemap.OfflinMapActivity.onZoomLevelChanged(OfflinMapActivity.java:189)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at com.offlinemap.MyMapView.dispatchDraw(MyMapView.java:176)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.View.draw(View.java:6743)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.View.draw(View.java:6743)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.View.draw(View.java:6743)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewRoot.draw(ViewRoot.java:1407)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.os.Looper.loop(Looper.java:123)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at java.lang.reflect.Method.invokeNative(Native Method)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at java.lang.reflect.Method.invoke(Method.java:521)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-11 17:20:40.161: ERROR/AndroidRuntime(5810): at dalvik.system.NativeStart.main(Native Method)