我已经这样做了:
public class LongTravlOverlay extends Overlay{
private Projection projection;
private List<GeoPoint> glist;
GeoPoint gP1;
GeoPoint gP2;
public LongTravlOverlay(Projection a,List<GeoPoint> b){
projection=a;
this.glist=b;
}
public void draw(Canvas canvas, MapView mapv, boolean shadow){
super.draw(canvas, mapv, shadow);
Paint mPaint = new Paint();
mPaint.setDither(true);
mPaint.setColor(Color.BLUE);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(3);
for(GeoPoint g1:glist)
{
if(gP1!=null)
{
gP1=gP2;
gP2=new GeoPoint(g1.getLatitudeE6(),g1.getLongitudeE6());
}
else
{
gP1=new GeoPoint(g1.getLatitudeE6(),g1.getLongitudeE6());
gP2=gP1;
continue;
}
Point p1 = new Point();
Point p2 = new Point();
Path path = new Path();
projection.toPixels(gP1, p1);
projection.toPixels(gP2, p2);
path.moveTo(p2.x, p2.y);
path.lineTo(p1.x,p1.y);
canvas.drawPath(path, mPaint);
}
}
}
它起作用并在所有点之间画线。唯一的问题是在第一个点和最后一个点之间还有一条线最终与其他点的路径相交。我该如何删除它?