Java Code Examples for com.google.android.gms.maps.model.PolylineOptions#addAll()

The following examples show how to use com.google.android.gms.maps.model.PolylineOptions#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GglMapAiPoint2PointManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void drawPointLine(LatLng latLngDevice) {
    if (this.pointMarker != null) {
        LatLng latLng = this.pointMarker.getPosition();
        this.latLngs.clear();
        this.latLngs.add(latLng);
        this.latLngs.add(latLngDevice);
        if (this.polyline == null) {
            PolylineOptions polylineOptions = new PolylineOptions();
            polylineOptions.addAll(this.latLngs);
            polylineOptions.color(this.context.getResources().getColor(R.color.x8_drone_inface_line)).zIndex(50.0f);
            polylineOptions.width(4.0f);
            if (this.polyline != null) {
                this.polyline.remove();
            }
            this.polyline = this.googleMap.addPolyline(polylineOptions);
            this.polyline.setPattern(PATTERN_DASHED);
        }
        this.polyline.setPoints(this.latLngs);
    }
}
 
Example 2
Source File: DriverMapActivity.java    From UberClone with MIT License 6 votes vote down vote up
@Override
public void onRoutingSuccess(ArrayList<Route> route, int shortestRouteIndex) {
    if(polylines.size()>0) {
        for (Polyline poly : polylines) {
            poly.remove();
        }
    }

    polylines = new ArrayList<>();
    //add route(s) to the map.
    for (int i = 0; i <route.size(); i++) {

        //In case of more than 5 alternative routes
        int colorIndex = i % COLORS.length;

        PolylineOptions polyOptions = new PolylineOptions();
        polyOptions.color(getResources().getColor(COLORS[colorIndex]));
        polyOptions.width(10 + i * 3);
        polyOptions.addAll(route.get(i).getPoints());
        Polyline polyline = mMap.addPolyline(polyOptions);
        polylines.add(polyline);

        Toast.makeText(getApplicationContext(),"Route "+ (i+1) +": distance - "+ route.get(i).getDistanceValue()+": duration - "+ route.get(i).getDurationValue(),Toast.LENGTH_SHORT).show();
    }

}
 
Example 3
Source File: NearbyLocationActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onRoutingSuccess(ArrayList<Route> route, int j) {
    if (polylines.size() > 0) {
        for (Polyline poly : polylines) {
            poly.remove();
        }
    }

    polylines = new ArrayList<>();
    //add route(s) to the map.
    for (int i = 0; i < route.size(); i++) {

        //In case of more than 5 alternative routes
        int colorIndex = i % COLORS.length;

        PolylineOptions polyOptions = new PolylineOptions();
        polyOptions.color(getResources().getColor(COLORS[colorIndex]));
        polyOptions.width(10 + i * 3);
        polyOptions.addAll(route.get(i).getPoints());
        Polyline polyline = mMap.addPolyline(polyOptions);
        polylines.add(polyline);
    }
}
 
Example 4
Source File: GglMapAiLineManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public Polyline getPolyline(int index, Polyline pl, int color) {
    PolylineOptions polylineOptions = new PolylineOptions();
    polylineOptions.addAll(pl.getPoints());
    polylineOptions.color(this.context.getResources().getColor(color)).zIndex(3.0f);
    polylineOptions.width(4.0f);
    Polyline line = this.googleMap.addPolyline(polylineOptions);
    line.setPattern(PATTERN_DASHED);
    return line;
}
 
Example 5
Source File: CampusMapActivity.java    From utexas-utilities with Apache License 2.0 5 votes vote down vote up
/**
 * Does the actual drawing of the route polyline, based on the geo points provided in the navset
 *
 * @param navSet Navigation set bean that holds the route information, incl. geo pos
 * @param color  Color in which to draw the lines
 */
private void drawPath(Deque<LatLng> navSet, int color) {
    clearAllMapRoutes();
    PolylineOptions polyOpt = new PolylineOptions()
            .color(color)
            .width(5f);
    polyOpt.addAll(navSet);
    Polyline routePolyline = mMap.addPolyline(polyOpt);
    polylineMap.put(routePolyline.getId(), routePolyline);
}
 
Example 6
Source File: Renderer.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a LineString to the map as a Polyline
 *
 * @param polylineOptions contains relevant styling properties for the Polyline
 * @param lineString      contains coordinates for the Polyline
 * @return Polyline object created from given LineString
 */
private Polyline addLineStringToMap(PolylineOptions polylineOptions,
                                    LineString lineString) {
    // Add coordinates
    polylineOptions.addAll(lineString.getGeometryObject());
    Polyline addedPolyline = mPolylines.addPolyline(polylineOptions);
    addedPolyline.setClickable(polylineOptions.isClickable());
    return addedPolyline;
}
 
Example 7
Source File: HistorySingleActivity.java    From UberClone with MIT License 4 votes vote down vote up
@Override
public void onRoutingSuccess(ArrayList<Route> route, int shortestRouteIndex) {

    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    builder.include(pickupLatLng);
    builder.include(destinationLatLng);
    LatLngBounds bounds = builder.build();

    int width = getResources().getDisplayMetrics().widthPixels;
    int padding = (int) (width*0.2);

    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);

    mMap.animateCamera(cameraUpdate);

    mMap.addMarker(new MarkerOptions().position(pickupLatLng).title("pickup location").icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pickup)));
    mMap.addMarker(new MarkerOptions().position(destinationLatLng).title("destination"));

    if(polylines.size()>0) {
        for (Polyline poly : polylines) {
            poly.remove();
        }
    }

    polylines = new ArrayList<>();
    //add route(s) to the map.
    for (int i = 0; i <route.size(); i++) {

        //In case of more than 5 alternative routes
        int colorIndex = i % COLORS.length;

        PolylineOptions polyOptions = new PolylineOptions();
        polyOptions.color(getResources().getColor(COLORS[colorIndex]));
        polyOptions.width(10 + i * 3);
        polyOptions.addAll(route.get(i).getPoints());
        Polyline polyline = mMap.addPolyline(polyOptions);
        polylines.add(polyline);

        Toast.makeText(getApplicationContext(),"Route "+ (i+1) +": distance - "+ route.get(i).getDistanceValue()+": duration - "+ route.get(i).getDurationValue(),Toast.LENGTH_SHORT).show();
    }

}