随着新地点的到来,路线正在更新。每个位置都在画布上绘制为Bitmap
图像。
if (!routeList.isEmpty() && !nodeList.isEmpty()) {
// draw route
for (int i = 0; i < routeList.size() - 1; i++) {
PointF goal3 = new PointF(nodeList.get(routeList.get(i)).x, nodeList.get(routeList.get(i)).y);
PointF goal4 = new PointF(nodeList.get(routeList.get(i + 1)).x, nodeList.get(routeList.get(i + 1)).y);
sourceToViewCoord(goal3, vPin5);
sourceToViewCoord(goal4, vPin6);
path.moveTo(vPin5.x, vPin5.y);
path.lineTo(vPin6.x, vPin6.y);
canvas.drawPath(path, paint);
}
PointF goal1 = new PointF(nodeList.get(routeList.get(0)).x, nodeList.get(routeList.get(0)).y);
sourceToViewCoord(goal1, vPin3);
float vX1 = vPin3.x - (location_img.getWidth() / 2);
float vY1 = vPin3.y - location_img.getHeight() / 2;
canvas.drawBitmap(location_img, vX1, vY1, paint);//Location drawing on canvas as a bitmap(image)
PointF goal2 = new PointF(nodeList.get(routeList.get(routeList.size() - 1)).x, nodeList.get(routeList.get(routeList.size() - 1)).y);
sourceToViewCoord(goal2, vPin4);
float vX2 = vPin4.x - (pin_red.getWidth() / 2);
float vY2 = vPin4.y - pin_red.getHeight();
canvas.drawBitmap(pin_red, vX2, vY2, paint);//Arrival point is drawn on the canvas as a bitmap(image)
}