1)我找到一种方法来显示地图上的折线实时位置更新用户。我已经这样做,但它不准确。下面是显示我的GIF我正在努力实现。谷歌地图的实时路线和显示路线的历史
实施例:
2)亦一旦用户用它做,我需要保存的路线,并通过与折线地图上绘制再次显示它。
以下是我所做的。
在点击按钮,我触发与MIN_TIME_BW_UPDATES = 10sec
和0 meters
@Override
public void onLocationChanged(Location location) {
LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
if (flag == 0) //when the first update comes, we have no previous points,hence this
{
prev = current;
flag = 1;
}
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(current, 18);
googleMap.animateCamera(update);
googleDirection = new GoogleDirection(new TaskCompleted() {
@Override
public void callBack(List<List<HashMap<String, String>>> routes) {
addPolyLineToMap(routes);
}
});
googleDirection.execute(prev, current, "mode=walking");
prev = current;
}
googleDirection
的位置更新,只是用纬度,经度和行驶模式下API调用。 addPolyLineToMap
是一种将多段线添加到地图的方法。
请有利于优化我的逻辑