Fixing routing app so it no longer uses deprecated methods.
Also changed the list so it displays the route instructions instead of
the street name.
package com.esri.samples.na.find_route;
+import java.util.ArrayList;
import java.util.List;
import com.esri.arcgisruntime.geometry.Envelope;
@@ -82,7 +83,7 @@ public class FindRouteSample extends Application {
// create a control panel
VBox vBoxControl = new VBox(6);
- vBoxControl.setMaxSize(200, 300);
+ vBoxControl.setMaxSize(400, 300);
vBoxControl.getStyleClass().add("panel-region");
Label directionsLabel = new Label("Route directions:");
@@ -109,10 +110,10 @@ public class FindRouteSample extends Application {
routeGraphic = new Graphic(shape, new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, BLUE_COLOR, 2));
routeGraphicsOverlay.getGraphics().add(routeGraphic);
- // get route street names
- route.getDirectionManeuvers().stream().flatMap(mvr -> mvr.getManeuverMessages().stream()).filter(ms -> ms
- .getType().equals(DirectionMessageType.STREET_NAME)).forEach(st -> directionsList.getItems().add(st
- .getText()));
+ // get the direction text for each maneuver
+ for(DirectionManeuver step : route.getDirectionManeuvers()) {
+ directionsList.getItems().add(step.getDirectionText());
+ }
resetButton.setDisable(false);
findButton.setDisable(true);
@@ -175,9 +176,10 @@ public class FindRouteSample extends Application {
Point stop2Loc = new Point(-1.3036911787723785E7, 3839935.706521739, ESPG_3857);
// add route stops
- List<Stop> routeStops = routeParameters.getStops();
+ List<Stop> routeStops = new ArrayList<Stop>();
routeStops.add(new Stop(stop1Loc));
routeStops.add(new Stop(stop2Loc));
+ routeParameters.setStops(routeStops);
// add route stops to the stops overlay
SimpleMarkerSymbol stopMarker = new SimpleMarkerSymbol(Style.CIRCLE, BLUE_COLOR, 14);
