我能够在位置更新中检索新的lat和long值,并将新的lat和long更新为各自的textview,如下所示:
private Polyline route = null;
private PolylineOptions routeOpts = null;
private boolean drawTrack = true;
private void updateUI() {
if (mCurrentLocation != null) {
tvLat.setText(String.valueOf(mCurrentLocation.getLatitude()));
tvLng.setText(String.valueOf(mCurrentLocation.getLongitude()));
tvUpdateTime.setText(mLastUpdateTime);
routeOpts = new PolylineOptions().color(Color.BLUE)
.width(3)
.geodesic(true);
route = mMap.addPolyline(routeOpts);
route.setVisible(drawTrack);
LatLng newPoint = new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude());
List<LatLng> points = route.getPoints();
points.add(newPoint);
route.setPoints(points);
}
}
我正在关注这个问题here。我想要做的是位置更新,将绘制折线。所以基本上折线会随着用户在跟踪路线时的移动而增加。文本视图中的位置正在更新,但折线未显示。