Reputation: 21562
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?
@Override
public void draw(android.graphics.Canvas canvas, MapView mapView,
boolean shadow) {
Point po = mapView.getProjection().toPixels(mapView.getMapCenter(),
null);
// 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
canvas.drawBitmap(BitmapFactory.decodeResource(mapView.getResources(),
R.drawable.map_marker_v), po.x, po.y, null);
}
Edit: fixed type
Upvotes: 3
Views: 1040
Reputation: 87430
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.
Upvotes: 5
Reputation: 91796
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.
Upvotes: 1