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);
}
答案 0 :(得分:0)
你已经覆盖了超类draw()方法。您需要使用以下方法在您的方法中调用它:
super.draw(canvas, mapView, shadow);