2011-05-09 2 views
1

제거, 그리고 경로 경로 제거 || 라인 안드로이드 구글지도 GPS를 사용하여 Google지도

public boolean draw(Canvas canvas, MapView mapView, boolean shadow, 
       long when) { 
      super.draw(canvas, mapView, shadow); 


    GeoPoint p = new GeoPoint((int) (29.987574219703674 * 1E6), 
      (int) (31.44225418567575 * 1E6)); 
    GeoPoint p2 = new GeoPoint((int) (29.98763859272003 * 1E6), 
      (int) (31.44235074520111 * 1E6)); 
    GeoPoint p3 = new GeoPoint((int) (29.98718498160553* 1E6), 
      (int) (31.442527770996094 * 1E6)); 
    GeoPoint p4= new GeoPoint((int) (29.98739718380868 * 1E6), 
     (int) (31.442527770886084 * 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); 

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


    super.draw(canvas, mapView, shadow); 
    // el super de 3shnnn to addd koloooo overlay w path 
    canvas.drawPath(path, paint); 

} 

enter code here

을 만들기 그래서 내가 경로 제거에 Path1에게 표창을 제거하려면! 도와주세요

답변

2

"drawPath"라는 부울 값을 만드는 옵션이 있습니다. . 그럼 당신은 당신이 원하는 때 다시 그려보기를 강제로 true로 경로 설정 "drawPath '를 그려 View.Invalidate를 호출 할 때

public boolean draw(Canvas canvas, MapView mapView, boolean shadow, 
      long when) { 
     super.draw(canvas, mapView, shadow); 
    if(drawPath){ 
     // path drawing logic goes here 
    } 
} 

: if 문에 경로를 그리기 위해 모든 로직을 넣어 경로를 제거하고 "drawPath"를 false로 설정하고 View.Invalidate를 호출하십시오.

+0

이 수정을 시도합니다. – exequielc

관련 문제