I'm trying to draw some points (around 200) in a MapOverlay and
noticed that the application gets slow and the phone becomes
unresponsive. Here's my code:

MapOverlay mapOverlay = new MapOverlay();
List<Overlay> listOfOverlays = mapa.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
...

class MapOverlay extends com.google.android.maps.Overlay
{
    Cursor c;
    Bitmap bmp;

    private MapOverlay()
    {
        ...initialize Bitmap and then Cursor with around 200 points taken
from a database...
    }

    @Override
    public boolean draw(Canvas canvas, MapView mapView,boolean shadow,
long when)
    {
        super.draw(canvas, mapView, shadow);

          for (int f=0;f<c.getcount();f++) {
                c.moveToPosition(f);
                Point pt=new Point();
                mapView.getProjection().toPixels(new
GeoPoint(c.getInt(0),c.getInt(1)),pt);
                canvas.drawBitmap(bmp, pt.x,pt.y-16, null);
                Log.i(TAG,"Drawing point "+f);
        }
...

After adding the Log.i message I found the problem, the loop is run
endlessly (note that the phone is quiet and there's nothing happening
in the background):

I/XP     (10507): Drawing point 0
I/XP     (10507): Drawing point 1
...
I/XP     (10507): Drawing point 199
I/XP     (10507): Drawing point 0
I/XP     (10507): Drawing point 1
...
I/XP     (10507): Drawing point 199

Is this a "normal" behaviour, a bug in the OS or am I doing something
wrong?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to