route simulation with driving directions using javascript

3024
0
07-07-2015 12:28 AM
jimmiraza
New Contributor

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
++;
  
}

0 Kudos
0 Replies