Skip to content

Commit 4966ee0

Browse files
committed
PR feedback
1 parent 3bfcf4d commit 4966ee0

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

find-route/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ For simplicity, the sample comes loaded with a start and end stop. You can tap o
1414

1515
## How it works
1616

17-
1. Create a `RouteTask` using a URL to an online route service.
18-
2. Generate default `RouteParameters` using `routeTask.createDefaultParameters()`.
19-
3. Set `returnDirections` on the parameters to true.
20-
4. Add `Stop`s to the parameters `stops` collection for each destination.
21-
5. Solve the route using `routeTask.solveRoute(routeParameters)` to get a `RouteResult`.
22-
6. Iterate through the result's `Route`s. To display the route, create a graphic using the geometry from `route.routeGeometry`. To display directions, use `route.directionManeuvers`, and for each `DirectionManeuver`, display `DirectionManeuver.directionText`.
17+
1. Set the `ArcGISEnvironment.applicationContext` to use a `RouteTask`
18+
2. Create a `RouteTask` using a URL to an online route service.
19+
3. Generate default `RouteParameters` using `routeTask.createDefaultParameters()`.
20+
4. Set `returnDirections` on the parameters to true.
21+
5. Add `Stop`s to the parameters `stops` collection for each destination.
22+
6. Solve the route using `routeTask.solveRoute(routeParameters)` to get a `RouteResult`.
23+
7. Iterate through the result's `Route`s. To display the route, create a graphic using the geometry from `route.routeGeometry`. To display directions, use `route.directionManeuvers`, and for each `DirectionManeuver`, display `DirectionManeuver.directionText`.
2324

2425
## Relevant API
2526

find-route/src/main/java/com/esri/arcgismaps/sample/findroute/MainActivity.kt

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,20 @@ class MainActivity : AppCompatActivity() {
226226
// when the user taps a maneuver, set the viewpoint to that portion of the route
227227
onItemClickListener =
228228
AdapterView.OnItemClickListener { _, _, position, _ ->
229-
// remove any graphics that are not the two stops and the route graphic
230-
if (graphicsOverlay.graphics.size > 3) {
231-
graphicsOverlay.graphics.removeAt(graphicsOverlay.graphics.size - 1)
232-
}
233-
// set the viewpoint to the selected maneuver
234-
val geometry = directions[position].geometry
235-
if (geometry != null) {
229+
directions[position].geometry?.let { geometry ->
230+
// set the viewpoint to the selected maneuver
236231
mapView.setViewpoint(
237232
Viewpoint(geometry.extent, 20.0)
238233
)
234+
// create a graphic with a symbol for the maneuver and add it to the graphics overlay
235+
val selectedRouteSymbol = SimpleLineSymbol(
236+
SimpleLineSymbolStyle.Solid,
237+
Color.green, 5f
238+
)
239+
graphicsOverlay.graphics.add(Graphic(geometry, selectedRouteSymbol))
240+
// collapse the bottom sheet
241+
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
239242
}
240-
// create a graphic with a symbol for the maneuver and add it to the graphics overlay
241-
val selectedRouteSymbol = SimpleLineSymbol(
242-
SimpleLineSymbolStyle.Solid,
243-
Color.green, 5f
244-
)
245-
graphicsOverlay.graphics.add(Graphic(geometry, selectedRouteSymbol))
246-
// collapse the bottom sheet
247-
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
248243
}
249244
}
250245

0 commit comments

Comments
 (0)