2011-05-01 3 views
0

안드로이드이 코드는 HelloOverlayItem 클래스에서 행해진 경로를 추가한다. 문제는 내가이 방법을 넣으면 더 오버레이 항목 그냥 경로를 표시하지 않고 내가 그것을 제거 할 때 오버레이 항목은 그녀의 당신은 슈퍼 클래스 무승부() 메소드를 오버라이드 (override) 한 방법android 오버레이 아이템을 가진 경로 메소드

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

입니다 표시입니다. 방법으로 다음과 같이 호출해야합니다.

super.draw(canvas, mapView, shadow); 
+0

정말 고마워요. – anji

관련 문제