use of com.mapbox.mapboxsdk.annotations.Polyline in project androidApp by InspectorIncognito.
the class RouterPlugin method changeRoute.
public void changeRoute(Route newRoute) {
for (Polyline polyline : polylineList) {
polylineEngine.removePolyline(mapboxMap, polyline);
}
polylineList = polylineEngine.addRoutePolyline(mapboxMap, newRoute);
busStopEngine.updateBusStopSource(newRoute.busStops);
}
use of com.mapbox.mapboxsdk.annotations.Polyline in project androidApp by InspectorIncognito.
the class PolylineEngine method addRoutePolyline.
public List<Polyline> addRoutePolyline(MapboxMap mapboxMap, Route route) {
if (busRouteEndFeature == null) {
setupPolylineVars(mapboxMap);
}
List<Location> firstList = route.route.get(0).getPoints();
Feature startPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(firstList.get(0).getLongitude(), firstList.get(0).getLatitude())));
List<Location> lastList = route.route.get(route.route.size() - 1).getPoints();
Feature endPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(lastList.get(lastList.size() - 1).getLongitude(), lastList.get(lastList.size() - 1).getLatitude())));
busRouteStartFeature = FeatureCollection.fromFeatures(new Feature[] { startPoint });
busRouteEndFeature = FeatureCollection.fromFeatures(new Feature[] { endPoint });
refreshSourceWithFeatures(busRouteStartSource, busRouteStartFeature);
refreshSourceWithFeatures(busRouteEndSource, busRouteEndFeature);
List<Polyline> polylineArrayList = new ArrayList<>(route.route.size());
for (InnerPolyline polyline : route.route) {
polylineArrayList.add(mapboxMap.addPolyline(new PolylineOptions().addAll(toLatLng(polyline.getPoints())).color(getColor(polyline)).width(4)));
}
return polylineArrayList;
}
Aggregations