zeta243 / osmdroid

Automatically exported from code.google.com/p/osmdroid
1 stars 0 forks source link

Can't draw in Overlay when shadow = true #347

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To reproduce: Run the code below.

Problem: I expect to see a red circle with a black dot in the middle, however, 
I only see the black dot.
It seems that my code cannot successfully draw anything when shadow=true

I am using osmdroid-android-3.0.8.

Here is the code:

import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.Overlay;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class OsmShadowDrawTest extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        test();
    }

    public void test()
    {
        LinearLayout mainLayout = new LinearLayout(this);
        setContentView(mainLayout);
        MapView oMap = new org.osmdroid.views.MapView(this, null);
        oMap.getOverlays().add(new ShadowOverlay(this));
        mainLayout.addView(oMap,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
    }

    class ShadowOverlay extends Overlay
    {
        public ShadowOverlay(Context context)
        {
            super(context);
        }

        @Override
        protected void draw(Canvas canvas, MapView map, boolean shadow)
        {
            //draw a bulls-eye: A large red circle, with a black middle
            //it should draw the red when shadow = true and
            //the center circle when shadow = false, but it
            //only draws the middle.
            if (shadow)
            {
                //ISSUE: NEVER DRAWS THIS!!!
                Paint paint = new Paint();
                paint.setColor(Color.RED);
                canvas.drawCircle(10, 10, 200, paint);
            }
            else
            {
                Paint paint = new Paint();
                paint.setColor(Color.BLACK);
                canvas.drawCircle(10, 10, 10, paint);
            }
        }
    }
}

Original issue reported on code.google.com by grego...@gmail.com on 24 May 2012 at 9:36

GoogleCodeExporter commented 9 years ago

Original comment by neilboyd on 24 May 2012 at 7:01

GoogleCodeExporter commented 9 years ago
The attached patch fixes it, but I'm not sure why TilesOverlay is messing it up.

Original comment by neilboyd on 24 May 2012 at 7:11

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks. Will you include this fix in the next release?

Original comment by grego...@gmail.com on 25 May 2012 at 8:10

GoogleCodeExporter commented 9 years ago
Does it work?  I didn't test it very thoroughly which is why I just attached a 
patch instead of immediately committing it.

Original comment by neilboyd on 25 May 2012 at 9:07

GoogleCodeExporter commented 9 years ago
It works in my code! I will report here if I discover any problems with the 
patch.

Original comment by grego...@gmail.com on 25 May 2012 at 9:49

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1102.

Original comment by neilboyd on 31 May 2012 at 8:03