Androidでシングルタップ方式でマーカーを描画しようとしています。マーカーを描画すると描画されますが、描画に時間がかかります。つまり、30〜40ミリ秒かかり、2〜3秒かかる場合があります。これは、描画メソッドを持つクラスのコードです。
public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> overlayItemList = new ArrayList<OverlayItem>();
public MyItemizedOverlay(Drawable pDefaultMarker,
ResourceProxy pResourceProxy) {
super(pDefaultMarker, pResourceProxy);
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean arg2) {
super.draw(canvas, mapView, arg2);
// ---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);
// ---add the marker---
Bitmap bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_darkblue);
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_green);
Bitmap bmp2 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_bue);
Bitmap bmp3 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
Bitmap bmp4 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
Bitmap bmp5 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
Bitmap bmp6 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
if (count == 1) {
int caller = getIntent().getIntExtra("button", 0);
switch (caller) {
case R.id.btMap:
canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 50, null);
bmp.recycle();
break;
case R.id.imageButton1:
canvas.drawBitmap(bmp1, screenPts.x, screenPts.y - 50, null);
bmp1.recycle();
break;
case R.id.imageButton2:
canvas.drawBitmap(bmp2, screenPts.x, screenPts.y - 50, null);
bmp2.recycle();
break;
case R.id.imageButton3:
canvas.drawBitmap(bmp3, screenPts.x, screenPts.y - 50, null);
bmp3.recycle();
break;
case R.id.imageButton4:
canvas.drawBitmap(bmp4, screenPts.x, screenPts.y - 50, null);
bmp4.recycle();
break;
case R.id.imageButton5:
canvas.drawBitmap(bmp5, screenPts.x, screenPts.y - 50, null);
bmp5.recycle();
break;
case R.id.imageButton6:
canvas.drawBitmap(bmp6, screenPts.x, screenPts.y - 50, null);
bmp6.recycle();
break;
}
}
// Bitmap bmp = BitmapFactory.decodeResource(getResources(),
// R.drawable.pin_annotation_green);
// if (count == 1) {
// canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 50, null);
// }
}