/** * Builds an overlay for the road shape with a default (and nice!) style. * @return route shape overlay */ public static Polyline buildRoadOverlay(Road road){ return buildRoadOverlay(road, 0x800000FF, 5.0f); }
private boolean createPolyline() { if (map == null || road.mStatus == Road.STATUS_INVALID || road.mStatus == Road.STATUS_TECHNICAL_ISSUE) return false;// some error with the road roadOverlay = RoadManager.buildRoadOverlay(road); roadOverlay.setColor(context.getResources().getColor(R.color.colorAccent)); roadOverlay.setWidth(16); roadOverlay.setGeodesic(true); // Drawable nodeIcon = context.getResources().getDrawable(R.drawable.ic_location); // for (int i = 0; i < road.mNodes.size(); i++) { // RoadNode node = road.mNodes.get(i); // Marker nodeMarker = new Marker(map); // nodeMarker.setPosition(node.mLocation); // nodeMarker.setIcon(nodeIcon); // nodeMarker.setTitle("Step " + i); // map.getOverlays().add(nodeMarker); // nodeMarker.setSnippet(node.mInstructions); // nodeMarker.setSubDescription(Road.getLengthDurationText(context, node.mLength, node.mDuration)); // Drawable icon = context.getResources().getDrawable(R.drawable.ic_filter_selected); // nodeMarker.setImage(icon); // } map.getOverlays().add(roadOverlay); map.invalidate(); return true; }
mRoadOverlays = new Polyline[roads.length]; for (int i=0; i<roads.length; i++) { Polyline roadPolyline = RoadManager.buildRoadOverlay(roads[i]); mRoadOverlays[i] = roadPolyline; if (mWhichRouteProvider == GRAPHHOPPER_BICYCLE || mWhichRouteProvider == GRAPHHOPPER_PEDESTRIAN) {
Toast.makeText(this, "Error when loading the road - status=" + road.mStatus, Toast.LENGTH_SHORT).show(); Polyline roadOverlay = RoadManager.buildRoadOverlay(road); map.getOverlays().add(roadOverlay);