ここに私が達成しようとしているもののスクリーンショットがあります
マップの各オーバーレイ項目に一意のラベル (数字など) を追加したいと思います。オーバーレイアイテムを追加してマップに表示するという基本的な部分を完了しました。しかし、これは私が長い間立ち往生している場所です
ここに私が達成しようとしているもののスクリーンショットがあります
マップの各オーバーレイ項目に一意のラベル (数字など) を追加したいと思います。オーバーレイアイテムを追加してマップに表示するという基本的な部分を完了しました。しかし、これは私が長い間立ち往生している場所です
関数を使用OverlayItem
して、同じ上に異なるマーカーを追加できます。ItemizedOverlay
overlayItem.setMarker(drawable);
Drawable
これを機能させるには、 :に境界を設定する必要があります。
Drawable icon1 = getResources().getDrawable(R.drawable.icon1);
Drawable icon2 = getResources().getDrawable(R.drawable.icon2);
icon1.setBounds(0, 0, icon1.getIntrinsicWidth(), icon1.getIntrinsicHeight());
icon2.setBounds(0, 0, icon2.getIntrinsicWidth(), icon2.getIntrinsicHeight());
OverlayItem item1 = new OverlayItem(new Point(48858290, 2294450),
"Tour Eiffel", "La tour Eiffel");
OverlayItem item2 = new OverlayItem(new Point(48873830, 2294800),
"Arc de Triomphe", "L'arc de triomphe");
item1.setMarker(icon1);
item2.setMarker(icon2);
マーカーの最大数と同じ数のビットマップが必要になります。ただし、ビットマップに動的にテキストを描画するよりも高速です。それは携帯電話であり、プロセッサは高速ではありません。とにかくビットマップにテキストを描画したい場合は、Iiは本当に簡単です。次のように実行できます。
//get a reference on the ImageView
ImageView iv = (ImageView)findViewById(R.id.myImage);
// load the marker image
Bitmap myRefBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.icon);
// create a mutable bitmap with the same size as the marker image
Bitmap myWrittenBitmap = Bitmap.createBitmap(myRefBitmap.getWidth(),
myRefBitmap.getHeight(), Bitmap.Config.ARGB_4444);
// create a Canvas on which to draw and a Paint to write text.
Canvas canvas = new Canvas(myWrittenBitmap);
Paint txtPaint = new Paint();
txtPaint.setColor(Color.RED);
txtPaint.setTextSize(12);
txtPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
txtPaint.setTypeface(Typeface.DEFAULT_BOLD);
//draw ref bitmap then text on our canvas
canvas.drawBitmap(myRefBitmap, 0, 0, null);
canvas.drawText("Droid", 5, 15, txtPaint);
// set the new written bitmap into the ImageView
iv.setImageBitmap(myWrittenBitmap);