AnsweredAssumed Answered

route simulation with driving directions using javascript

Question asked by jimmiraza on Jul 7, 2015

How to simulate route with driving directions. driving direction should be speak turn by turn like real gps navigator application. I have set of driving directions and i want to speak it on each driving direction reached. i am doing like below. here distance is the distance between last gps possition to current gps possition . and dd is the variable for driving direction which will be increase on each driving direction reached.

 

var tempP;

  
var xy = DrivingDirectionGeomatry.XY[dd];

  
if (DrivingDirectionGeomatry != undefined)
  
var length = dojo.number.format(DrivingDirectionGeomatry.Attributes[dd].length)
  
var point = new esri.geometry.Point({ "x": xy[0], "y": xy[1], "spatialReference": { " wkid": appLayers.map.spatialReference } });
  tempP
= point;
  
var d = dojo.number.format(distance);
  
var remDistance = dojo.number.format(length - d);
  
if (remDistance < 0) {
  
return;
  
}
  
if ((remDistance <= 100 && remDistance > 0 || remDistance == length) && DrivingDirectionGeomatry.IsTraval[dd] == false) {
  txtToSpeech
.Speak(DrivingDirectionGeomatry.Attributes[dd].text, TextToSpeech.SpeechRate.VeryLow, TextToSpeech.PitchRate.Normal);
  
DrivingDirectionGeomatry.IsTraval[dd] = true;
  lastPossition
.lat = null;
  lastPossition
.lon = null;
  currentPossition
.distance = null;
  dd
++;
  
}

Outcomes