title: Drawing a line between 2 points using Google Maps
body: <p>My problem is that I want to create a method that when I invoke it giving it two GeoPoint's I want it to draw a line between the two points and I haven't been able to do this.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>public class MyOverlays extends ItemizedOverlay&lt;OverlayItem&gt; {
  
  private ArrayList&lt;OverlayItem&gt; mapOverlays = new ArrayList&lt;OverlayItem&gt;();
  private Context context;
  private int lastestIndex;
  private Projection projection;
  private Canvas canvas;
  private MapView mapv;
  private boolean shadow;
  
  public MyOverlays(Context context, Drawable defaultMarker, String player) {
      super(boundCenterBottom(defaultMarker));
      this.context = context;
  }
  
  @Override
  protected OverlayItem createItem(int i) {
      return mapOverlays.get(i);
  }
  
  @Override
  public int size() {
      return mapOverlays.size();
  
  }
  
  public void setPj(Projection projection) {
      this.projection = projection;
  
  }
  
  public void draw(Canvas canvas, MapView mapv, boolean shadow) {
      super.draw(canvas, mapv, shadow);
      this.canvas = canvas;
      this.mapv = mapv;
      this.shadow = shadow;
  
      // Configuring the paint brush
  
  }
  </code></pre>
  
  <p>Test method ideally i would want to pass 2 geopoints to draw a line between them</p>
  
  <pre><code>  public void test() {
      super.draw(canvas, mapv, shadow);
      Paint mPaint = new Paint();
      mPaint.setDither(true);
      mPaint.setColor(Color.RED);
      mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
      mPaint.setStrokeJoin(Paint.Join.ROUND);
      mPaint.setStrokeCap(Paint.Cap.ROUND);
      mPaint.setStrokeWidth(4);
  
      GeoPoint gP1 = new GeoPoint(34159000, 73220000);// starting point
      GeoPoint gP2 = new GeoPoint(33695043, 73050000);// End point Islamabad
  
      GeoPoint gP4 = new GeoPoint(33695043, 73050000);// Start point Islamabad
      GeoPoint gP3 = new GeoPoint(33615043, 73050000);// End Point Rawalpindi
  
      Point p1 = new Point();
      Point p2 = new Point();
      Path path1 = new Path();
  
      Point p3 = new Point();
      Point p4 = new Point();
      Path path2 = new Path();
      projection.toPixels(gP2, p3);
      projection.toPixels(gP1, p4);
  
      path1.moveTo(p4.x, p4.y);// Moving to Abbottabad location
      path1.lineTo(p3.x, p3.y);// Path till Islamabad
  
      projection.toPixels(gP3, p1);
      projection.toPixels(gP4, p2);
  
      path2.moveTo(p2.x, p2.y);// Moving to Islamabad location
      path2.lineTo(p1.x, p1.y);// Path to Rawalpindi
  
      canvas.drawPath(path1, mPaint);// Actually drawing the path from
                                      // Abbottabad to Islamabad
      canvas.drawPath(path2, mPaint);// Actually drawing the path from
                                      // Islamabad to Rawalpindi
      this.populate();
  }
  </code></pre>