Search in sources :

Example 1 with Polyline

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);
}
Also used : Polyline(com.mapbox.mapboxsdk.annotations.Polyline)

Example 2 with Polyline

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;
}
Also used : InnerPolyline(cl.smartcities.isci.transportinspector.router.InnerPolyline) Polyline(com.mapbox.mapboxsdk.annotations.Polyline) InnerPolyline(cl.smartcities.isci.transportinspector.router.InnerPolyline) ArrayList(java.util.ArrayList) Feature(com.mapbox.services.commons.geojson.Feature) Location(android.location.Location) PolylineOptions(com.mapbox.mapboxsdk.annotations.PolylineOptions)

Aggregations

Polyline (com.mapbox.mapboxsdk.annotations.Polyline)2 Location (android.location.Location)1 InnerPolyline (cl.smartcities.isci.transportinspector.router.InnerPolyline)1 PolylineOptions (com.mapbox.mapboxsdk.annotations.PolylineOptions)1 Feature (com.mapbox.services.commons.geojson.Feature)1 ArrayList (java.util.ArrayList)1