次のようなオーバーレイを描画する場合は、次のようにします。
したがって、基本的にあなたがしなければならないことは、キャンバスの助けを借りて背景ボックスにcustomImageを課すことです。この実装を使用すると、キャンバスからBitmapDrawableを効果的に作成し、それを「ItemizedOverlay」のマーカーとして割り当てることができます。これが探していたアイテム化されたオーバーレイのタイプである場合、アイテム化されたオーバーレイクラスの描画機能をオーバーライドする必要はありません。次のコードを使用して、コンストラクターでItemizedOverlayに割り当てることができるBitmapDrawableを作成するだけです。これを行う関数は次のとおりです。
public BitmapDrawable imageOnDrawable(int drawableBackground, Bitmap customImage)
{
//The following line is optional but I'd advise you to minimize the size of
//the size of the bitmap (using a thumbnail) in order to improve draw
//performance of the overlays (especially if you are creating a lot of overlays).
Bitmap customImageThumbnail = ThumbnailUtils.extractThumbnail(
customImage, 100, 100);
Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId);
bm = Bitmap.createScaledBitmap(bm, 112, 120, false);
Canvas canvas = new Canvas(bm);
canvas.drawBitmap(bm, 0, 0, null);
// The 6,6 in the below line refer to the offset of the customImage/Thumbnail
// from the top-left corner of the background box (or whatever you want to use
// as your background)
canvas.drawBitmap(customImageThumbnail, 6, 6, null);
return new BitmapDrawable(bm);
}