Select to view content in your preferred language

ROUTE TASK - GET DRIVING DIRECTIONS TO an XY COORDINATE

761
3
04-14-2010 12:47 PM
JuneAcosta
Frequent Contributor
I need a interactive map for all our trails and trailheads on top of Bing Map or the ESRI Street Map. The user would need to get driving directions to the trails from a static Address, which will be our address for City Hall. I will start with the "Get Driving Directions" sample- is it possible to use a lat/long instead of an actual address?

Thanks
0 Kudos
3 Replies
KellyHutchins
Esri Notable Contributor
Sure this is possible. If you look at the 'Get Driving Directions' sample you'll see that the input address is geocoded and the x,y values of the best match are used to create a new graphic which is are used as the inputs to the route task.

  if (type === "from") {
          routeParams.stops.features[0] = map.graphics.add(new esri.Graphic(stop.location, fromSymbol, { address:stop.address, score:stop.score }));
        }
        else if (type === "to") {
          routeParams.stops.features[1] = map.graphics.add(new esri.Graphic(stop.location, toSymbol, { address:stop.address, score:stop.score }));
        }


In the above code you can replace stop.location with a new point that contains the lat,lon values instead.
0 Kudos
JuneAcosta
Frequent Contributor
Kelly,

Thanks I got it to map the lat/lon, but what do I replace the "{ address:stop.address, score:stop.score }" with since I am not gecoding an a real address?
0 Kudos
KellyHutchins
Esri Notable Contributor
This text is displayed in the direction info - you could associate a location name rather than address if you wish, for example if I wanted driving directions to display ESRI Redlands and San Diego convention center instead of an address I could  add an address attribute with the following information:
        
var fromLoc = new esri.geometry.Point( -117.194958859564,34.0573637535114,map.spatialReference);
routeParams.stops.features[0] = map.graphics.add(new esri.Graphic(fromLoc, fromSymbol,{address:"ESRI Redlands"}));

var toLoc = new esri.geometry.Point(-117.163797351249,32.7075263536336,map.spatialReference);   routeParams.stops.features[1] = map.graphics.add(new esri.Graphic(toLoc, toSymbol,{address:"San Diego Convention Center"}));
0 Kudos