/** * 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 void getRoadBetweenLocations() { RoadManager roadManager = new OSRMRoadManager(context); ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>(); waypoints.add(new GeoPoint(fromLatitude, fromLongitude)); GeoPoint endPoint = new GeoPoint(toLatitude, toLongitude); waypoints.add(endPoint); road = roadManager.getRoad(waypoints); }
case GRAPHHOPPER_FASTEST: roadManager = new GraphHopperRoadManager(graphHopperApiKey, false); roadManager.addRequestOption("locale="+locale.getLanguage()); break; case GRAPHHOPPER_BICYCLE: roadManager = new GraphHopperRoadManager(graphHopperApiKey, false); roadManager.addRequestOption("locale="+locale.getLanguage()); roadManager.addRequestOption("vehicle=bike"); roadManager.addRequestOption("locale="+locale.getLanguage()); roadManager.addRequestOption("vehicle=foot"); return null; return roadManager.getRoads(waypoints);
GeoPoint endPoint = new GeoPoint(48.4, -1.9); waypoints.add(endPoint); Road road = roadManager.getRoad(waypoints); if (road.mStatus != Road.STATUS_OK) Toast.makeText(this, "Error when loading the road - status=" + road.mStatus, Toast.LENGTH_SHORT).show(); Polyline roadOverlay = RoadManager.buildRoadOverlay(road); map.getOverlays().add(roadOverlay);
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) {