2012-07-27 48 views
6

Tôi đã vẽ đường thẳng giữa các địa chỉ. thành công của nó rút ra. khi chúng ta nhìn thấy bản đồ, đường biên trông giống như pixelated khi so sánh với hình vẽ tiếp theo. làm thế nào để hợp nhất dòng?Vẽ đường thẳng giữa các địa chỉ trên android

enter image description here

Mã của tôi là ở đây,

@Override 
public void draw(Canvas canvas, MapView mapview, boolean shadow) { 
    super.draw(canvas, mapview, shadow); 
    if(! routeIsActive) return; 

    mapview.getProjection().toPixels(locpoint, pp);  // Converts GeoPoint to screen pixels 

    int xoff = 0; 
    int yoff = 0; 
    int oldx = pp.x; 
    int oldy = pp.y; 
    int newx = oldx + xoff; 
    int newy = oldy + yoff; 

    paint.setAntiAlias(true); 
    paint.setDither(true); 
      paint.setStrokeWidth(7); 
    for(int i=0; i<numberRoutePoints-1; i++) 
    { 
     switch(routeMode.get(i)) 
     { 
     case 0: 
      paint.setColor(Color.parseColor("#666666")); 
      break; 
     case 1: 
      paint.setColor(Color.parseColor("#0EA7D6")); 
      break; 
     case 2: 
      paint.setColor(Color.parseColor("#654321")); 
      break; 
     case 3: 
      paint.setColor(Color.parseColor("#123456")); 
      break; 
     } 

     mapview.getProjection().toPixels(routePoints.get(i), pold); 
     oldx = pold.x; 
     oldy = pold.y; 
     mapview.getProjection().toPixels(routePoints.get(i+1), pnew); 
     newx = pnew.x; 
     newy = pnew.y; 

     canvas.drawLine(oldx, oldy, newx, newy, paint); 
    } 

} 

Trả lời

3

Bạn nên thay đổi phong cách của đối tượng sơn như thế này:

paint.setStrokeCap(Cap.ROUND); 
+0

Xin chào @AndyRes. cảm ơn anh bạn. làm việc tốt. – RVG

2

Nếu bạn vẽ một vòng tròn ở đầu và cuối mỗi dòng (đường kính vòng tròn phải có chiều cao dòng), tôi nghĩ rằng nó sẽ làm các việc lừa hoặc có thể drawRoundRect của vải có thể làm điều đó tốt

Các vấn đề liên quan