travel mode as a param of routeTask.solveWithParameters?

4109
2
05-11-2016 10:21 PM
DanielCosta2
New Contributor

Guys, I'm trying to get travel time from the iOS SDK, but a parameter for that doesn't seem to exist just like the one we have at the JS SDK.

I'm using this code to solve the Route:

       if self.routeTask == nil {

            self.routeTask = AGSRouteTask.routeTaskWithURL(NSURL(string: "http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World"), credential: cred) as! AGSRouteTask

             self.routeTask.delegate = self

        }

        let params = AGSRouteTaskParameters()

        let firstStop = AGSStopGraphic(geometry: myLocation, symbol: nil, attributes: nil)

        let lastStop = AGSStopGraphic(geometry: destination, symbol: nil, attributes: nil)

        params.setStopsWithFeatures([firstStop, lastStop])

        params.returnRouteGraphics = true

        params.returnDirections = true

        params.findBestSequence = false

        params.preserveFirstStop = true

        params.preserveLastStop = true

        params.outSpatialReference = self.mapView.spatialReference

        params.ignoreInvalidLocations = false

        self.routeTask.solveWithParameters(params)

Can you guys help me how to achieve that here? I didn't find anything at the documentation!

Thanks a lot!

0 Kudos
2 Replies
DiveshGoyal
Esri Regular Contributor

AGSRouteResult has properties like totalMinutes, totalMiles, etc that you can use.

10.2.5: AGSRouteResult Class Reference

But you'll probably have to set up the accumulateAttributes of AGSRouteTaskParameters to include the time and distance attributes.

10.2.5: AGSRouteTaskParameters Class Reference

This is how it is done by the offline routing sample - arcgis-runtime-samples-ios/ViewController.swift at master · Esri/arcgis-runtime-samples-ios · GitHub... - but you might have to change the attribute names to match the ones that are available with the  route.arcgis.com service

0 Kudos
DanielCosta2
New Contributor

Thanks for your answer, Divesh!

But maybe my question wans't clear enough, as I already have all those attribuites in hand:

I need to get the estimated travel time (and also the best route) not by driving, as the standard task returns me, but by walking.

I have an app for an open space urban exposition, and people will visit each location walking from one place to another. Right now, all routes I got are related to car driving.

Is it possible to achieve with the iOS SDK?

In the other hand, if I was the one who misunderstood your answer, could you show me an actual example to achieve walking routes and times?

Thanks a lot!