开发者

Android Draw route path Draw function [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to draw a path on a map using kml file?

Android draw a path on a mapView from a large amount of longitude/latitude points

In my android application I use this method in "draw" Overlay class for draw route on map.

Can someone tell me if this method is good (in terms of performance) for route draw on map or I must to put code in Thread ??

I'm new to android.

`

public synchronized void draw(Canvas canvas, MapView mapView, boolean shadow) {

  if (pointsAndTimes.isEmpty()) {

   return;


  }
  Projection projection = mapView.getProjection();
  Paint paint = new Paint();
  paint.setARGB(250, 255, 0, 0);
  paint.setAntiAlias(true);
  paint.setFakeBoldText(true);
  paint.setStrokeWidth(4);
  paint.setAlpha(100);  



  for (int i = 0; i < pointsAndTimes.size(); i++) {
   PointAndTime pointAndTime = pointsAndTim开发者_C百科es.get(i);
   Point point = projection.toPixels(pointAndTime.getGeoPoint(), null);

   if (i == pointsAndTimes.size() - 1) {

   } else {
    PointAndTime nextPointAndTime = pointsAndTimes.get(i + 1);

    Point nextPoint = projection.toPixels(nextPointAndTime
      .getGeoPoint(), null);
    canvas.drawLine(point.x, point.y, nextPoint.x, nextPoint.y,
      paint);
   }


  }
  mapView.invalidate();


 }`

Thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜