Using ItemizedOverlay and OverlayItem In Android Beta 0.9

For the sake of completeness I’ll repeat the discussion on Reto’s post over at the Android Groups here.

It seems that if you set the bounds on your drawable it does the trick:

Drawable defaultMarker = r.getDrawable(R.drawable.icon);

// You HAVE to specify the bounds! It seems like the markers are drawn
// through Drawable.draw(Canvas) and therefore must have its bounds set
// before drawing.
defaultMarker.setBounds(0, 0, defaultMarker.getIntrinsicWidth(),
    defaultMarker.getIntrinsicHeight());

MyItemizedOverlay markers = new MyItemizedOverlay(defaultMarker);
overlays.add(markers);

By the way, the above is shamelessly ripped from the demo at MarcelP.info. Also, here is a good howto.

Leave a Comment