I have a task to show 458 markers for display on Android maps. And to avoid performance issues, I update the data on the map using an AsyncTask instance.
Here is a short scenario of what I'm doing.
- I select the latitude / longitude of 458 locations around the UK.
- I run a loop, and according to the Android training blog, I add them to the
ItemizedOverlay class - After each 50th iteration, I call the
publishProgress method to place 50 markers on the map.
After the 50th iteration, the stream goes to onProgressUpdate via publishProgress and here is my onProgressUpdate method onProgressUpdate
// MapOverLays = mapView.getOverlays(); //This line was called in asyc task constructor // Hello Overlay is an instance of ItemizedOverlay. mapOverlays.add(helloOverLay); //MapView.getController - Also called in Constructor controller.setZoom(12); controller.animateTo(centerPoint); controller.setCenter(centerPoint);
This code throws an ArrayIndexOutOfBoundException , and logcat does not display any class from my module. Here is a logcat dump if it develops my problem.
12-07 11:34:48.644: ERROR/AndroidRuntime(508): java.lang.ArrayIndexOutOfBoundsException 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.google.android.maps.ItemizedOverlay.getIndexToDraw(ItemizedOverlay.java:211) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.google.android.maps.ItemizedOverlay.draw(ItemizedOverlay.java:240) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.google.android.maps.Overlay.draw(Overlay.java:179) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.google.android.maps.MapView.onDraw(MapView.java:476) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.View.draw(View.java:6535) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.drawChild(ViewGroup.java:1531) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.drawChild(ViewGroup.java:1529) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.View.draw(View.java:6538) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.widget.FrameLayout.draw(FrameLayout.java:352) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.drawChild(ViewGroup.java:1531) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.drawChild(ViewGroup.java:1529) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.View.draw(View.java:6538) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.widget.FrameLayout.draw(FrameLayout.java:352) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewRoot.draw(ViewRoot.java:1349) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewRoot.performTraversals(ViewRoot.java:1114) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.view.ViewRoot.handleMessage(ViewRoot.java:1633) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.os.Handler.dispatchMessage(Handler.java:99) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.os.Looper.loop(Looper.java:123) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at android.app.ActivityThread.main(ActivityThread.java:4363) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at java.lang.reflect.Method.invokeNative(Native Method) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at java.lang.reflect.Method.invoke(Method.java:521) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 12-07 11:34:48.644: ERROR/AndroidRuntime(508): at dalvik.system.NativeStart.main(Native Method)
PS I tested the application with relatively smaller (10) and relatively large (150) iterations instead of 50. But the application throws the same error.
android google-maps android-maps
Prasham
source share