ArcGIS Runtime Error Occurred. Set a breakpoint on C++ exceptions to see the original callstack and context for this error: Error Domain=com.esri.arcgis.runtime.error Code=15 "Invalid call."
My code:
public func startRoute(to destination: AGSPoint) {
queue.async { [weak self] in
guard let self = self else {
Logger.log(error: nil)
return
}
// set destination and start locations
self.destinationLocation = destination
self.startLocation = AGSPoint(clLocationCoordinate2D: self.positionManager.current.toCLLocation().coordinate)
self.routeTask = AGSRouteTask(databaseName: "", networkName: "")
self.routeTask.defaultRouteParameters { [weak self] (params: AGSRouteParameters?, error: Error?) in
guard let self = self else {
Logger.log(error: nil)
return
}
if let params = params {
params.returnDirections = true
params.returnStops = true
params.returnRoutes = true
params.outputSpatialReference = .wgs84()
params.setStops(self.makeStops())
self.routeParameters = params
// calculate route
self.routeTask.solveRoute(with: params) { [weak self] result, error in
guard let self = self else { return }
if let result = result {
// success
self.didSolveRoute(with: .success(result))
} else if let error = error {
// failure
self.didSolveRoute(with: .failure(error))
}
}
} else if let error = error {
guard let del = self.delegateelse { return }
del.updateNavigationView(direction: "Error \((error as NSError).code)", directions: [AGSDirectionManeuver]())
Logger.routing.error("Failed to get route parameters with error \(error.localizedDescription, privacy: .public)")
}
}
}
}
func startEsriNavigation(to point: AGSPoint) {
guard let positionManager = positionManagerelse {
return
}
routeService = RMRouteService(positionManager: positionManager)
routeService.delegate = self
routeService.startRoute(to: point)
mapToolsView.navigationPoint = point
isRouting = true
self.toggleMapTools(toolIndex: 1)
DispatchQueue.main.async { [weak self] in
self?.esriMap.locationDisplay.start()
self?.navigationButton.isHidden = false
}
}