I have created a function whereby I am able to track the user's route and create a polyline. I have been trying to save it to Firebase as - routeId, routeName, lat, lng
The method I have used is, everytime on a location change, the user's new lat and long will be saved into Firebase, a routeName that the user has set and (currently) a static 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);
}
However, when I retrieve the data using an adapter, like so,
@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 + ": ");
}
what I get is a listview of each child of "route", which means if the routeName I had set was "Walking"
, there will be a list filled with "Walking".
I want to save all the lat and longs of the same routeName together, and then retrieve them in a listview so when the user selects the routeName I can regenerate the polyline on the map with the lat and lngs from the database. Could this be done? I don't mind not using Firebase, but an online server would be more optimal for backup.