Android Draw route path Draw function [duplicate]
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
精彩评论