Let the Directions widget draw on a specified graphics layer

Idea created by a.schaefer-esri-de-esridist on Mar 10, 2014
    • mikeneal
    The Directions Widgets of the ArcGIS API for JavaScript paints per default on the map.graphics layer. It would be nice if the widget has a parameter where you can specify the graphics layer where it draws all it results to.

    Why? The map.graphics layer is the most basic container for graphics. In bad code everything is drawn there. Better is to choose an own Graphics-Layer (like "myRouteGraphicsLayer") where the results are drawn. Then you know that this is the container where all your route and location data is. And it's a lot easier to work with the stuff there.

    This graphics layer should be specified in the properties of the Directions Widget. The changes take place in Directions.js.

    Get rid of lines like these:  (this.options.map.graphics.add(this.get("mergedRouteGraphic")), (b = this.get("mergedRouteGraphic").getDojoShape()) && b.moveToBack());

    Make it like this: 

    (this.options.specifiedgraphicslayer.graphics.add(this.get("mergedRouteGraphic")), (b = this.get("mergedRouteGraphic").getDojoShape()) && b.moveToBack());

    Thanks. :)