Hello all,
I'm trying to get the route data using the below code and getting the following error
private fun findRoute() {
// generate a route with directions and stops for navigation
val routeTask = RouteTask(context, BuildConfig.ARC_GIS_ROUTING_URL)
val routeParametersFuture = routeTask.createDefaultParametersAsync()
routeParametersFuture.addDoneListener {
// define the route parameters
val routeParameters = routeParametersFuture.get().apply {
try {
val routeStops = listOf(
// Destination stop
Stop(Point(longitude, latitude, SpatialReferences.getWgs84()))
)
setStops(routeStops)
isReturnDirections = true
isReturnStops = true
isReturnRoutes = true
} catch (e: Exception) {
when (e) {
is InterruptedException, is ExecutionException -> {
val error = "Error getting the default route parameters: " + e.message
Toast.makeText(activity, error, Toast.LENGTH_LONG)
.show()
Log.e(TAG, error)
}
else -> throw e
}
}
}
val routeResultFuture = routeTask.solveRouteAsync(routeParameters)
routeResultFuture.addDoneListener {
try {
// get the route geometry from the route result
val routeResult = routeResultFuture.get()
val routeGeometry = routeResult.routes[0].routeGeometry
// create a graphic for the route geometry
val routeGraphic = Graphic(
routeGeometry,
SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLUE, 5f)
)
// add it to the graphics overlay
binding.acceptMissionMapView.graphicsOverlays[0].graphics.add(routeGraphic)
// set the map view view point to show the whole route
binding.acceptMissionMapView.setViewpointAsync(Viewpoint(routeGeometry.extent))
this.routeTask = routeTask
this.routeResult = routeResult
this.routeParameters = routeParameters
} catch (e: Exception) {
when (e) {
is InterruptedException, is ExecutionException -> {
val error = "Error creating the route result: " + e.message
Toast.makeText(context, error, Toast.LENGTH_LONG)
.show()
Log.e(TAG, error)
}
else -> throw e
}
}
}
}
}
and this is the error that I'm getting:
Hi,
Whats the version of Runtime SDK you are using? Were you able to execute this find-route sample,
https://github.com/Esri/arcgis-runtime-samples-android/tree/main/kotlin/find-route
Thanks
Rama