我已经创建了一个函数,可以跟踪用户的路线并创建一条折线。我一直在尝试将它保存到Firebase中,因为我使用的方法是,每次在位置更改时,用户的新lat和long都将保存到Firebase中,routeName,routeName,lat,lng如何在数据库中保存跟踪多义线?
用户已设置和(当前)静态routeId。
if (mCurrentLocation != null) {
String newLat = String.valueOf(mCurrentLocation.getLatitude());
String newLng = String.valueOf(mCurrentLocation.getLongitude());
LatLng newPoint = new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude());
List<LatLng> points = route.getPoints();
points.add(newPoint);
route.setPoints(points);
Map<String, String> routePoint = new HashMap<String,String>();
routePoint.put("routeID", "124");
routePoint.put("routeName", saveRouteTitle);
routePoint.put("lat", newLat);
routePoint.put("lng", newLng);
mFirebaseRef.push().setValue(routePoint);
}
然而,当我使用的适配器,像这样,
@Override
protected void populateView(View view, Route route) {
// Map a Chat object to an entry in our listview
String routeName = route.getRouteName();
int routeID = route.getRouteID();
String lat = route.getLat();
String lng = route.getLng();
TextView tvRouteName = (TextView) view.findViewById(R.id.tvRouteName);
tvRouteName.setText(routeName + ": ");
}
什么,我得到的是“路线”的每一个孩子,这意味着如果routeName我已经设置的列表视图检索数据是"Walking"
,会出现一个充满“散步”的列表。 我想一起保存相同routeName的所有纬度和长度,然后在列表视图中检索它们,因此当用户选择routeName时,我可以使用数据库中的lat和lngs重新生成地图上的折线。这可以做到吗?我不介意不使用Firebase,但在线服务器对于备份更为理想。
杰伊回答! –