AnsweredAssumed Answered

problem get infomation directions router

Question asked by sinharcgis on Jul 10, 2015
Latest reply on Jul 21, 2015 by timw1984

not get information points of router,   returns Locattion 1, loacation2 ....

i use firebug get messages atribute of routeResults

"Input field [field] was not mapped to a field in the network analysis class "Stops"."

 

below image firebug

router.png

information direction:

ro2.png

my code:

$("#tuyen1").click(function () {

                  var routeTask, routeParams;

                  routeTask = new esri.tasks.RouteTask("http://localhost/arcgis/rest/services/NetworkanalystGT/NetworkanalystGT/NAServer/Route");

                  routeParams = new esri.tasks.RouteParameters();

                  routeParams.stops = new esri.tasks.FeatureSet();

                  routeParams.returnDirections = true;

                  routeParams.returnRoutes = true;

                  routeParams.routeName = true;

                  routeTask.on("solve-complete", showRoute);

                  routeTask.on("error", errorHandler);

 

 

                  var queryTaskstuyenDL = new esri.tasks.QueryTask(stringservice + "Bandochuyende/DULICH_03052015/MapServer/35");

                  var querytuyenDL = new esri.tasks.Query();

                  querytuyenDL.returnGeometry = true;

                  querytuyenDL.where = "upper(PHANLOAI_LUU) like 'ĐÌNH, CHÙA'";

                  querytuyenDL.outSpatialReference = myMap.spatialReference;

                  querytuyenDL.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;

                  queryTaskstuyenDL.execute(querytuyenDL, function (featureSet) {

                      myMap.graphics.clear();

                      var resultFeatures = featureSet.features;

                      if (resultFeatures.length > 0) {

                          for (var i = 0, il = resultFeatures.length; i < il; i++) {

                          

                              var graphic = resultFeatures[i];                        

                              routeParams.stops.features.push(resultFeatures[i]);

                              graphic.setSymbol(symbolmochc);                         

                              myMap.infoWindow.setFeatures([resultFeatures[i]]);                          

                              myMap.graphics.add(graphic);                             

                          }

                          routeTask.solve(routeParams);

                      }

                  });

              });                     

              function showRoute(evt) {

                  var segmentGraphic;

                  var directions = evt.result.routeResults[0].directions;

                  var directionFeatures = directions.features;

                  var routeSymbol = new esri.symbol.SimpleLineSymbol().setColor(new dojo.Color([0, 120, 255, 0.5])).setWidth(4);

                  myMap.graphics.add(evt.result.routeResults[0].route.setSymbol(routeSymbol));

                  myMap.setExtent(directions.extent, true);

                  var directionsInfo = evt.result.routeResults[0].directions.features;

                  var totalDistance = dojo.number.format(directions.totalLength);

                  var totalLength = dojo.number.format(directions.totalTime);

                  data = dojo.map(directionsInfo, function (feature, index) {

                      return {

                          "detail": feature.attributes.text,

                          "distance": dojo.number.format(feature.attributes.length, { places: 2 }),

                          "index": index

                      }

                  });

                  var griddirection = new dgrid.Grid({

                      renderRow: renderList,

                      showHeader: true

                  }, "griddirection");

                  griddirection.renderArray(data);

                  griddirection.on(".dgrid-row:click", function (evt) {

                      var index = griddirection.row(evt).id;

                      var segment = directionFeatures[index];

                      var segmentSymbol = new esri.symbol.SimpleLineSymbol().setColor(new dojo.Color([255, 0, 00, 0.5])).setWidth(10);

                      myMap.setExtent(segment.geometry.getExtent(), true);

                      if (!segmentGraphic) {

                          segmentGraphic = myMap.graphics.add(new esri.Graphic(segment.geometry, segmentSymbol));

                      } else {

                          segmentGraphic.setGeometry(segment.geometry);

                      }

                  });

                  $('#griddirection').show();

                  $('#griddirection').draggable();

              }

              function errorHandler(err) {

                  alert("An error occured\n" + err.message + "\n");

 

              }

 

 

 

Outcomes