我有两个图像一个圆圈和一个箭头。我计算我当前的 GPS 坐标和地图上选择的坐标之间的距离。现在我需要将箭头放在圆形图像上并放在箭头计算距离上。我该如何实施?就像是
编辑:如何将箭头图像放在中心并在箭头上放置文字?
public class CompassOverlay extends Overlay
{
private float angle;
public CompassOverlay(float angle)
{
this.angle=angle;
}
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
super.draw(canvas, mapView, shadow);
Bitmap back =BitmapFactory.decodeResource(mapView.getResources(),R.drawable.tfm_compass_back);
Bitmap arrowBitmap = BitmapFactory.decodeResource(mapView.getResources(),R.drawable.tfm_compass_arrow);
// Create blank bitmap of equal size for back
Bitmap canvasBitmap = back.copy(Bitmap.Config.ARGB_8888, true);
canvasBitmap.eraseColor(0x00000000);
// Create canvas
Canvas canvasBack = new Canvas(canvasBitmap);
// Create rotation matrix
Matrix rotateMatrix = new Matrix();
rotateMatrix.setRotate(angle, canvasBack.getWidth()/2, canvasBack.getHeight()/2);
canvas.drawBitmap(back, 0.0f, 0.0f, null);
// Draw bitmap onto canvas using matrix
canvasBack.drawBitmap(arrowBitmap, rotateMatrix, null);
BitmapDrawable bitmapDrawable= new BitmapDrawable(canvasBitmap);
canvas.drawBitmap(bitmapDrawable.getBitmap(), 0.0f, 0.0f, null);
return true;
}
}