Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android将路径方法与覆盖项一起使用_Android - Fatal编程技术网

android将路径方法与覆盖项一起使用

android将路径方法与覆盖项一起使用,android,Android,Android我添加了一个路径(通过输入两个位置的行)这段代码是在我的HelloOverlayItem类中完成的!问题是,当我使用此方法时,没有覆盖项仅显示路径,当我删除它时,覆盖项显示她就是方法 enter code here public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) { GeoPoint p = new GeoPoint((int) (29.9870

Android我添加了一个路径(通过输入两个位置的行)这段代码是在我的HelloOverlayItem类中完成的!问题是,当我使用此方法时,没有覆盖项仅显示路径,当我删除它时,覆盖项显示她就是方法

enter code here
    public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) 
{


GeoPoint     p = new GeoPoint((int) (29.98703241482666 * 1E6), (int) ( 31.439915891647359 * 1E6));
GeoPoint     p2=new GeoPoint((int) (29.987107515335083 * 1E6), (int) ( 31.43912136554718 * 1E6));
//GeoPoint   p3 = new GeoPoint((int) (29.98703241482666 * 1E6), (int) ( 31.439915891647359 * 1E6));
//GeoPoint   p4=new GeoPoint((int) (29.987107515335083 * 1E6), (int) ( 31.43912136554718 * 1E6));
  // Let's assume you've assigned values to these two GeoPoints now.

  Projection projection = mapView.getProjection();
  Point startingPoint = projection.toPixels(p, null);
  Point endingPoint = projection.toPixels(p2, null);
     //point startingPoint1 = projection.toPixels(p3, null);
     //Point endingPoint2 = projection.toPixels(p4, null);
     // Create the path containing the line between the two points.
  Path path = new Path();

  path.moveTo(startingPoint.x, startingPoint.y);
  path.lineTo(endingPoint.x, endingPoint.y);

  // Setup the paint.  You'd probably do this outside of the draw() method to be more efficient.
  Paint paint = new Paint();
  paint.setStyle(Paint.Style.STROKE);
  paint.setColor(Color.RED);

 // mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
 // mPaint.setStrokeJoin(Paint.Join.ROUND);
  //mPaint.setStrokeCap(Paint.Cap.ROUND);
  //mPaint.setStrokeWidth(2);
  // Can set other paint characteristics, such as width, anti-alias, color, etc....

  // Draw the path!
  canvas.drawPath(path, paint);
}

您已经重写了超类draw()方法。您需要在方法中使用以下命令调用它:

super.draw(canvas, mapView, shadow);