我已经试了几个小时,想弄清楚为什么我不能在将其添加到地图的覆盖层之前使用一个分项地图叠加层:
GeoPoint point;
OverlayItem overlayitem = new OverlayItem(point, "","");
MarkerOverlay.addOverlay(overlayitem);
如果我尝试在没有MarkerOverlay.addOverlay(overlayitem);
命令的情况下执行此操作,那么当我尝试添加新的覆盖层时,会出现以下问题:
public boolean onTap(GeoPoint point, MapView mapView)
{
if (mOverlays.size() > 0)
mOverlays.remove(0);
OverlayItem overlayitem = new OverlayItem(point, "", "");
mOverlays.add(overlay);
populate();
return true;
}
在我的ItemizedOverlay类中,我只是遇到了空引用异常(我不知道何时或为什么-当调试时它说没有可用的源代码)
有任何想法吗?
编辑: 这是我可以在logcat中找到的:
09-20 22:36:22.164: WARN/dalvikvm(311): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
这就是我认为的臭名昭著的异常:
09-20 22:36:22.293: ERROR/AndroidRuntime(311): java.lang.NullPointerException
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.google.android.maps.ItemizedOverlay.getItemsAtLocation(ItemizedOverlay.java:617)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.google.android.maps.ItemizedOverlay.getItemAtLocation(ItemizedOverlay.java:586)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.google.android.maps.ItemizedOverlay.handleMotionEvent(ItemizedOverlay.java:498)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.google.android.maps.ItemizedOverlay.onTouchEvent(ItemizedOverlay.java:572)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.google.android.maps.OverlayBundle.onTouchEvent(OverlayBundle.java:63)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.google.android.maps.MapView.onTouchEvent(MapView.java:625)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.view.View.dispatchTouchEvent(View.java:3709)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:852)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:822)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:822)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:822)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.os.Handler.dispatchMessage(Handler.java:99)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.os.Looper.loop(Looper.java:123)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at android.app.ActivityThread.main(ActivityThread.java:4363)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at java.lang.reflect.Method.invokeNative(Native Method)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at java.lang.reflect.Method.invoke(Method.java:521)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-20 22:36:22.293: ERROR/AndroidRuntime(311): at dalvik.system.NativeStart.main(Native Method)
09-20 22:36:22.394: ERROR/dalvikvm(311): Unable to open stack trace file '/data/anr/traces.txt': Permission denied