gpt4 book ai didi

java - 根据实时跟踪地理点动态绘制线条

转载 作者:行者123 更新时间:2023-12-01 05:31:51 25 4
gpt4 key购买 nike

我想在用户转向任何地方时动态地画一条线。当我们不断监听他的位置时,我正在努力研究如何使用用户地理点来绘制线条。我尝试过使用 moveTo 和 lineTo 但只能用于一行。感谢您提前的答复。!

更新:

public void draw(Canvas canvas, MapView mv, boolean shadow)
{
Projection projection = mv.getProjection();
ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>();
//Creating geopoints - ommited for readability
Path p = new Path();
for (int i = 0; i < geoPoints.size(); i++) {
if (i == geoPoints.size() - 1) {
break;
}
Point from = new Point();
Point to = new Point();
projection.toPixels(geoPoints.get(i), from);
projection.toPixels(geoPoints.get(i + 1), to);
p.moveTo(from.x, from.y);
p.lineTo(to.x, to.y);
}
Paint mPaint = new Paint();
mPaint.setStyle(Style.FILL);
mPaint.setColor(0xFFFF0000);
mPaint.setAntiAlias(true);
canvas.drawPath(p, mPaint);
super.draw(canvas, mv, shadow);
}

图片:

无论用户在哪里,线条的绘制都必须跟随。 draw track

最佳答案

您可以使用 Path更具体地说:

private final Path mPath;
................
mPath.lineTo(lastXCoord,lastYCoord);

关于java - 根据实时跟踪地理点动态绘制线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8854380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com