Search in sources :

Example 6 with PolylineOptions

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));
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature) PolylineOptions(com.mapbox.mapboxsdk.annotations.PolylineOptions) NonNull(android.support.annotation.NonNull)

Example 7 with PolylineOptions

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;
}
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)

Example 8 with PolylineOptions

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));
    }
}
Also used : ArrayList(java.util.ArrayList) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) Point(com.mapbox.geojson.Point) PolylineOptions(com.mapbox.mapboxsdk.annotations.PolylineOptions)

Aggregations

PolylineOptions (com.mapbox.mapboxsdk.annotations.PolylineOptions)8 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)3 Feature (com.mapbox.services.commons.geojson.Feature)3 NonNull (android.support.annotation.NonNull)2 ArrayList (java.util.ArrayList)2 Location (android.location.Location)1 InnerPolyline (cl.smartcities.isci.transportinspector.router.InnerPolyline)1 Point (com.mapbox.geojson.Point)1 Marker (com.mapbox.mapboxsdk.annotations.Marker)1 MarkerOptions (com.mapbox.mapboxsdk.annotations.MarkerOptions)1 PolygonOptions (com.mapbox.mapboxsdk.annotations.PolygonOptions)1 Polyline (com.mapbox.mapboxsdk.annotations.Polyline)1 MapboxMap (com.mapbox.mapboxsdk.maps.MapboxMap)1 MarkerData (com.mapbox.mapboxsdk.plugins.geojson.model.MarkerData)1 PolyData (com.mapbox.mapboxsdk.plugins.geojson.model.PolyData)1 PoiNodeRef (io.jawg.osmcontributor.model.entities.PoiNodeRef)1 WayMarkerOptions (io.jawg.osmcontributor.ui.utils.views.map.marker.WayMarkerOptions)1