TypeError: Cannot call method 'moveToBack' of null

Discussion created by mglassman91 on Jun 21, 2013
Latest reply on Jun 28, 2013 by JGravois-esristaff
I have been using the "Get driving directions" sample template with my own network analysis service. I have been having some trouble getting the graphics of the start and stop points and the route to appear. Additionally, when I changed from using an ESRI basemap to a Tiled Map Service I received this error when trying to run the sample in the JavaScript Sandbox: "TypeError: Cannot call method 'moveToBack' of null". Here is the code snippet where the error is occurring:
    //Show the result of the routing task.
    function showRoute(solveResult) {
      var data = [];
      if(grid) grid.refresh();
      var directions = solveResult.routeResults[0].directions;
      directionFeatures = directions.features;
      var routeSymbol = new esri.symbol.SimpleLineSymbol().setColor(new dojo.Color([0,0,255,0.5])).setWidth(4);
      //Add route to the map.
      var routeGraphic = new esri.Graphic(directions.mergedGeometry, routeSymbol);;
      map.setExtent(directions.extent, true);

I am not very experienced with coding with the exception of Python. When I comment out the line with "moveToBack" the error does not accur and the routing works but the graphics still do not appear. Any help anyone may be able to give would be greatly appreciated.