View Full Version : getting driving directions

07-13-2011, 03:55 AM
I'm sorry if this is in the wrong section...

I am not sure how to do it...

Here is the coding:

function displayTitle(name, x, y){
return name + " <a href='#' onClick='showDirectionsDialog(\""+name+"\", "+x+", "+y+")'><img src='images/direction.png' alt='Get driving directions'/></a>";

function showDirectionsDialog(name, x, y){
var d=dijit.byId("dialogDirections");

d.set("title", "Get directions to \""+name+"\"");



function getDirections(){
var frmX=document.getElementById("txtFrmX").value;
var frmY=document.getElementById("txtFrmY").value;
var toX=document.getElementById("txtToX").value;
var toY=document.getElementById("txtToY").value;

var routeData = new Route;
routeData.routeStops = frmX+","+frmY+";"+toX+","+toY;
routeData.routeMode = "DRIVE";
routeData.routeOption = "Shortest";

function showDirections(routeResults){
if (routeResults.results=="No results"){
alert("No directions found, please try other location.");


Here is the coding I have now:

function getDirections() {

var routeData = new Route;
routeData.routeStops = document.getElementById('txtTheme').value;
routeData.routeMode = document.getElementById('txtOtptFlds').value;
routeData.avoidERP = document.getElementById('txtExtent').value;
routeData.routeOption = "Shortest";

function showRouteData(routeResults)
if (routeResults.results=="No results"){
alert("No Route found, please try other location.")
else if (routeResults.results=="Stops more than nine"){
alert("Number of stops exceed than nine");
directions = routeResults.results.directions[0];

directionFeatures = directions.features;

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

var mergedGeometry = new esri.geometry.Polyline()

OneMap.map.graphics.add(new esri.Graphic(mergedGeometry, routeSymbol));
//Display the total time and distance of the route
document.getElementById("results").innerHTML = "<br /> &nbsp; Total distance: " + directions.summary.totalLength + "<br /> &nbsp; Total time: " + directions.summary.totalTime;

//List the directions and create hyperlinks for each route segment
for (var i=0;i<directions.features.length;i++)
var feature=directions.features[i]
document.getElementById("results").innerHTML= document.getElementById("results").innerHTML + '<br><u>' + parseInt(parseInt(i)+1) + ". " + feature.attributes.text + " (" + feature.attributes.length + ", " + feature.attributes.time + ")</u>"


I am not sure how to integrate my codings into the other codings.

There is a name of the place (lets say London) and a clickable icon by the side. When I click the icon, a dojo toolkit dialog box appear for me to enter my location (the other place, London, will be displayed in the dialog box) Click "Go" to get the directions...

I wish to have the directions also placed in a dialog box too...

Old Pedant
07-13-2011, 05:44 AM
You seem to have left out the most important thing:

What library are you basing this on???

It doesn't look like the Google Maps API to me. So what is it? Or is it Google and I don't recognize it?

Where's your include of the API code?

07-13-2011, 08:17 AM
i am using

there are coding provided in the link

Old Pedant
07-13-2011, 11:42 PM
So did you try asking for help at onemaphelpdesk@niit-tech.com.sg ??

I've never seen this product before. I don't know if many/any others here have.