Skip to content

Commit 2716eb2

Browse files
CalebRasnjarecha
andauthored
Update Shared/Samples/Find closest facility from point/FindClosestFacilityFromPointView.swift
Co-authored-by: Nimesh Jarecha <[email protected]>
1 parent 16e28cd commit 2716eb2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Shared/Samples/Find closest facility from point/FindClosestFacilityFromPointView.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,19 @@ private extension FindClosestFacilityFromPointView {
169169
// Create a route graphic for each incident in the result.
170170
let incidentsIndices = closestFacilityResult.incidents.indices
171171
let routeGraphics = incidentsIndices.compactMap { incidentIndex -> Graphic? in
172-
// Get the index for the facility closest to the given incident.
172+
// Get the index for the facility closest to the given incident and facility route.
173173
guard let closestFacilityIndex = closestFacilityResult.rankedIndexesOfFacilities(
174174
forIncidentAtIndex: incidentIndex
175-
).first else { return nil }
176-
177-
// Get the route for the facility and incident.
178-
let closestFacilityRoute = closestFacilityResult.route(
179-
toFacilityAtIndex: closestFacilityIndex,
180-
fromIncidentAtIndex: incidentIndex
181-
)
175+
).first,
176+
let closestFacilityRoute = closestFacilityResult.route(
177+
toFacilityAtIndex: closestFacilityIndex,
178+
fromIncidentAtIndex: incidentIndex
179+
) else {
180+
return nil
181+
}
182182

183183
// Create a graphic using the route's geometry.
184-
return Graphic(geometry: closestFacilityRoute?.routeGeometry, symbol: routeSymbol)
184+
return Graphic(geometry: closestFacilityRoute.routeGeometry, symbol: routeSymbol)
185185
}
186186

187187
graphicsOverlay.addGraphics(routeGraphics)

0 commit comments

Comments
 (0)