ArcGIS is already equipped with API service which calculates the shortest path between a start and an end point based on length, time etc. The following is how the service is called to returns in a RouteResult object, which in turn is used to draw a route on the map (I omit that part):

try {
            NAFeaturesAsFeature rfaf = new NAFeaturesAsFeature();
            // Create the stop points (start at our location, go to pressed location)
            ArrayList<StopGraphic> stopGraphics = new ArrayList<StopGraphic>();
            for(Point pt : directionStops){
                stopGraphics.add(new StopGraphic(pt));
            Graphic[] stopGraphicsPrim = new Graphic[stopGraphics.size()];
            stopGraphicsPrim = stopGraphics.toArray(stopGraphicsPrim);
            // Set the routing service output SR to our map service's SR
            mResults = A.getRouteTask().solve(A.getRouteParameter());
        } catch (Exception e) {
            mHandler.post(new Runnable() {
                public void run() {
                    Toast.makeText(getActivity(),"directions cannot be found ",Toast.LENGTH_SHORT).show();

I now have multiple destination points. Say, someone needs to visit 5 coordinates from its own location, but, he/she needs to follow a path which ends up in a shortest travel distance, having visited all the 5 destinations.

I could not find a service from ArcGIS server which provides me such a general path. If I just provide RouteParameter object with multiple stops with method: A.getRouteParameter().setStops(rfaf); the service will return a path in the given coordinate order. i.e. if my first stop coordinate is the farthest to the start coordinate (own current coordinate in my case), the the route first points to there instead of finding the closest one from the all given stops.

Now, are there any ways to find this shortest general path using any service (maybe apart from ArcGIS), or do I have to make multiple service calls between two points to eventually calculate the shortest general path? i.e. for N multiple stops I have to make Nx(N+1)/2 point to point service calls with the method: mResults = A.getRouteTask().solve(A.getRouteParameter());, as mentioned in the above code snippet.

1 Answer 1


The findBestSequence parameter on the RouteParameters class should re-order the stops in the most efficient order (depending on whether you want shortest or fastest route), from the API help :

Find Best Sequence

Gets or sets a value indicating whether the analysis should reorder stops to find the optimized route. The default is false.

Note using this you may wish to preserve the first and/or last stops if that's an origin and destination of the route, e.g.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.