views:

207

answers:

1

I am trying to display one png (drawable) on a map in about 300 points. I am retrieving the coordinates from a Sqlite table, dumping them in a cursor. When I try to display them by parsing through the cursor, it takes for ever for the images to be drawn, about .5 second per image. I find that to be suspiciously slow, so some insight on how I can increase performance would help. Here is the snippet of my code that does the rendering:

while (!mFlavorsCursor.isAfterLast())
            {

                Log.d("cursor",""+(i++));
              point = new GeoPoint(
                      (int)(mFlavorsCursor.getFloat(mFlavorsCursor.getColumnIndex(DataBaseHelper.KEY_LATITUDE))*1000000),
                      (int)(mFlavorsCursor.getFloat(mFlavorsCursor.getColumnIndex(DataBaseHelper.KEY_LONGITUDE))*1000000));
              overlayitem = new OverlayItem(point, "", "");
              itemizedoverlay.addOverlay(overlayitem);
              itemizedoverlay.doPopulate();
              mFlavorsCursor.moveToNext();
            }
            mapOverlays.add(itemizedoverlay);

I tried to isolate all the steps and it looks like the slow one is this:

itemizedoverlay.doPopulate();

This is a public method in my class that extends ItemizedOverlay that runs the private populate() method.

+1  A: 

Do not call doPopulate() until you have populated all the items.

CommonsWare
I tried that before. Performance stayed the same, took the same time for the images to appear on the map.
oviroa
You still should not call `doPopulate()` until you have populated all the items.
CommonsWare
OK, no problem. But how do I solve the performance issue?
oviroa
I don't know. If you can create a sample project that demonstrates the issue, post it somewhere and comment with a link here.
CommonsWare
OK, will do that.
oviroa
So, looks like the issue is gone after I recompiled the app. Very weird, must have been something with my computer, last night both the emulator and the phone versions were extremely slow. Today, after re-compiling it is running just fine.
oviroa