use of com.mapbox.mapboxsdk.annotations.PolylineOptions in project androidApp by InspectorIncognito.
the class BusStopPlugin method addBusRoutePolyline.
@NonNull
private Polyline addBusRoutePolyline(ArrayList<LatLng> points, int colorId) {
Feature startPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(points.get(0).getLongitude(), points.get(0).getLatitude())));
Feature endPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(points.get(points.size() - 1).getLongitude(), points.get(points.size() - 1).getLatitude())));
busRouteStartFeature = FeatureCollection.fromFeatures(new Feature[] { startPoint });
busRouteEndFeature = FeatureCollection.fromFeatures(new Feature[] { endPoint });
refreshSourceWithFeatures(busRouteStartSource, busRouteStartFeature);
refreshSourceWithFeatures(busRouteEndSource, busRouteEndFeature);
return mapboxMap.addPolyline(new PolylineOptions().addAll(points).color(ContextCompat.getColor(getContext(), colorId)).width(4));
}
use of com.mapbox.mapboxsdk.annotations.PolylineOptions 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;
}
use of com.mapbox.mapboxsdk.annotations.PolylineOptions in project mapbox-navigation-android by mapbox.
the class RerouteActivity method drawRoute.
private void drawRoute(DirectionsRoute route) {
List<LatLng> points = new ArrayList<>();
List<Point> coords = LineString.fromPolyline(route.geometry(), Constants.PRECISION_6).coordinates();
for (Point point : coords) {
points.add(new LatLng(point.latitude(), point.longitude()));
}
if (!points.isEmpty()) {
if (polyline != null) {
mapboxMap.removePolyline(polyline);
}
// Draw polyline on map
polyline = mapboxMap.addPolyline(new PolylineOptions().addAll(points).color(Color.parseColor("#4264fb")).width(5));
}
}
Aggregations