Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting driving directions

    I'm sorry if this is in the wrong section...

    I am not sure how to do it...

    Here is the coding:
    Code:
    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+"\"");
    
    document.getElementById("txtToX").value=x;
    document.getElementById("txtToY").value=y;
    
    d.show();
    }
    
    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.avoidERP=0;
    routeData.routeOption = "Shortest"; 
    routeData.GetRoute(showDirections);
    }
    
    function showDirections(routeResults){
    if (routeResults.results=="No results"){
    alert("No directions found, please try other location.");
    return;
    }
    
    }
    Here is the coding I have now:
    Code:
    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"; 
    routeData.GetRoute(showRouteData)
    }
    
    function showRouteData(routeResults)
    {
    if (routeResults.results=="No results"){
    alert("No Route found, please try other location.")
    return
    }
    else if (routeResults.results=="Stops more than nine"){
    alert("Number of stops exceed than nine");
    return;
    }
    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()
    
    mergedGeometry.addPath(routeResults.results.routes.features[0].geometry.paths[0])
    OneMap.map.graphics.clear();
    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...

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,733
    Thanks
    80
    Thanked 4,516 Times in 4,480 Posts
    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?

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i am using
    http://www.onemap.sg/api/help/

    there are coding provided in the link

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,733
    Thanks
    80
    Thanked 4,516 Times in 4,480 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •