これは、サークル内にサークルを描画し、現在の場所をサークルの中心として使用する以下のコードです。そして、私は現在の場所に星座マーカーを表示しています。
問題文:-
以下のコードは正常に機能していますが、私が抱えている唯一の問題は、Star Sign Marker
円の中心に来ていないことです。私はStar Sign Marker
(android.R.drawable.star_on)
常に円の中心にいる必要があります。
imageNames[0]
以下のコードの円の中心(星座マーカー)です。
どんな提案も私に大いに役立つでしょう。
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
super.draw(canvas, mapView, shadow);
Point screenPts = new Point();
mapView.getProjection().toPixels(pointToDraw, screenPts);
//--------------draw circle----------------------
Point pt = mapView.getProjection().toPixels(pointToDraw,screenPts);
Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setColor(0x30000000);
circlePaint.setStyle(Style.FILL_AND_STROKE);
int totalCircle=4;
int radius=40;
int centerimagesize=13;
for (int i = 1; i <= totalCircle; i ++) {
canvas.drawCircle(screenPts.x,screenPts.y, i*radius, circlePaint);
canvas.drawBitmap(BitmapFactory.decodeResource(getResources(),imageNames[i]), ((screenPts.x)+(i*radius)),(screenPts.y), null);
}
canvas.drawBitmap(BitmapFactory.decodeResource(getResources(),imageNames[0]), (screenPts.x-(centerimagesize/2)),(screenPts.y-(centerimagesize/2)), null);
super.draw(canvas,mapView,shadow);
return true;
}
以下は、エミュレータで現在取得しているスクリーンショットです。常に円の中心に星座が必要です。私はアンドロイド4.1を実行しています