Not understanding drawAt() method for

Trying to make an google maps overlay in an android program. Inside of my overlay's draw method, I have two ways of adding a pin. One of them works, and one does not. Unfortunately, the one that does not work is also the only one that has the ability to add a shadow! Any help?

public void draw( canvas, MapView mapView,
        boolean shadow) {

    Point po = mapView.getProjection().toPixels(mapView.getMapCenter(),

    // This does _not_ work, but I would really like it to!
    drawAt(canvas, mapView.getResources().getDrawable(R.drawable.map_marker_v),
           po.x, po.y, false);

    // This does work, but only does half the job
            R.drawable.map_marker_v), po.x, po.y, null);


Edit: fixed type

Asked by: Freddie790 | Posted: 24-01-2022

Answer 1

I think your problem may simply be that you haven't set the bounds on the drawable in drawAt(). You can either manually set the bounds using Drawable.setBounds(), or you can use ItemizedOverlay's convenience methods boundCenter() or boundCenterBottom().

I believe the reason the second method works is because with a decoded Bitmap you don't have to specify the bounds of the Drawable.

Answered by: Grace596 | Posted: 25-02-2022

Answer 2

At first sight, nothing stands out to me as to what could be causing your pin to not draw. But, I might have found a temporarily solution.

Looking on google lead me to this post where an user posts their version of an Overlay with the ability to add an icon along with a shadow. It might be what your looking for.

Hope this helps.

Answered by: Miller357 | Posted: 25-02-2022

Similar questions

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android