在Android中如何在google地图中绘制点与点之间的线

在Android中如何在google地图中绘制点与点之间的线,android,google-maps,path,overlay,Android,Google Maps,Path,Overlay,我已经写了一个程序,从android GPS读取位置;每个位置(long,lat)将被发送到远程服务器以保存并显示在网站地图中 我现在要做的是通过在点之间画一条线,在android中显示我的路径 直到现在我才找到充分的答案!那么如何做到这一点呢?您可以在点之间画一条线,如下所示: public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { Projection p

我已经写了一个程序,从android GPS读取位置;每个位置(long,lat)将被发送到远程服务器以保存并显示在网站地图中

我现在要做的是通过在点之间画一条线,在android中显示我的路径
直到现在我才找到充分的答案!那么如何做到这一点呢?

您可以在点之间画一条线,如下所示:

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);
  }

在“地图”中,如果进入“菜单”>“实验室”,则有一个称为“测量”的功能,可用于绘制线。它是为用户设计的,但也许您可以研究如何操作该程序MaticallyTanx,但我在Eclipse中找不到任何“地图”选项卡,所以它是Eclipse中的一项功能吗?还是另一个叫做“地图”的程序?