開發一個Android應用程序以繪製四條以上的線條並將它們連接起來以顯示爲多邊形。使用角度我找到座標在哪裏開始和結束線,然後我繪製mapview。但我的需要是,多邊形從底部開始第一行(與設備水平)。如何重新定位線路?幫我找到一個解決辦法..在mapview上重繪繪製的線
的圖像顯示了我真正的需要..
http://tinypic.com/view.php?pic=rbgoix&s=8#.U8S6NZSSy80
代碼:
m=0;
x[m]= (dis[m]*1000)*Math.sin((angle1[m])*Math.PI/180);
y[m]= (dis[m]*1000)*Math.cos((angle1[m])*Math.PI/180);
GeoPoint g = new GeoPoint((int)(x[m]),(int)(y[m]));
Point p=new Point();
projection.toPixels(g, p);
Path path=new Path();
l=pp.x;
o=pp.y;
for(m=1;m<j+1;m++)
{
x[m]= (dis[m]*1000)*Math.sin((angle1[m])*Math.PI/180);
y[m]= (dis[m]*1000)*Math.cos((angle1[m])*Math.PI/180);
GeoPoint g1 = new GeoPoint((int)(x[m]),(int)(y[m]));
Point p1=new Point();
projection.toPixels(g1, p1);
Path path1=new Path();
if(m!=j)
{
path1.moveTo(p.x, p.y);
path1.lineTo(p1.x, p1.y);
canvas.drawPath(path1, mPaint);
lPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawTextOnPath((sf.format(distance[m-1])).toString()+" ,"+m+" ,"+v[m], path1,10 ,20, lPaint);
}
else
{
p1.x=l;
p1.y=o;
path1.moveTo(p1.x, p1.y);
path1.lineTo(pp.x, pp.y);
canvas.drawPath(path1, mPaint);
lPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawTextOnPath((sf.format(distance[m-1])).toString()+" ,"+m, path1,10 ,20, lPaint);
}
//Toast.makeText(getApplicationContext(),"Angle"+distance[m], Toast.LENGTH_SHORT).show();
p.x=p1.x;
p.y=p1.y;
}
你有什麼試過在這裏發佈你的代碼 –