I'm just trying to display an icon of a man with a circle under his feet in the center of the MapView. Here's my Overlay code:
public class CenterOverlay extends Overlay
{
private Drawable d;
public CenterOverlay(Drawable drawable)
{
final int w = drawable.getIntrinsicWidth();
final int h = drawable.getIntrinsicHeight();
drawable.setBounds(0, 0, w, h);
this.d = drawable;
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{
final int mapCenterX = mapView.getWidth() / 2;
final int mapCenterY = mapView.getHeight() / 2;
final int x = mapCenterX - d.getIntrinsicWidth() / 2;
final int y = mapCenterY - d.getIntrinsicHeight();
drawAt(canvas, d, x, y, shadow);
}
}
The code to add the Overlay to the MapView is working fine (I can see the icon right where it's supposed to be). The problem is that the automagically generated shadow is in the wrong spot (about the icon's width to the left, and about halfway up the icon).
Thanks in advance for your help!