我已经编写了一个从Android GPS读取位置的程序;每个locatin(long,lat)将被发送到远程服务器以保存它并将其显示在网站地图中。
我现在要做的是通过在点之间画线来显示我在android中的路径 直到现在我才找到任何足够的答案!那怎么办呢?
答案 0 :(得分:0)
您可以在点之间画线:
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
Projection projection = mapView.getProjection();
if (shadow == false)
{
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);
Point point = new Point();
projection.toPixels(gp1, point);
/* mode=1 create the starting point */
if(mode==1)
{
RectF oval=new RectF(point.x - mRadius, point.y - mRadius,
point.x + mRadius, point.y + mRadius);
/* draw the circle with the starting point */
canvas.drawOval(oval, paint);
}
/* mode=2 draw the route line */
else if(mode==2)
{
Point point2 = new Point();
projection.toPixels(gp2, point2);
paint.setColor(Color.BLACK);
paint.setStrokeWidth(5);
paint.setAlpha(120);
/* draw the lint */
canvas.drawLine(point.x, point.y, point2.x,point2.y, paint);
}
/* mode=3 create the ending point */
else if(mode==3)
{
/* draw the line of the last part firstly to avoid error */
Point point2 = new Point();
projection.toPixels(gp2, point2);
paint.setStrokeWidth(5);
paint.setAlpha(120);
canvas.drawLine(point.x, point.y, point2.x,point2.y, paint);
/* define the RectF object */
RectF oval=new RectF(point2.x - mRadius,point2.y - mRadius,
point2.x + mRadius,point2.y + mRadius);
/* draw the circle with the ending point */
paint.setAlpha(255);
canvas.drawOval(oval, paint);
}
}
return super.draw(canvas, mapView, shadow, when);
}