Select to view content in your preferred language

Get Driving Directions sample - broken?

710
3
07-27-2012 06:01 AM
BrettGreenfield__DNR_
Occasional Contributor II
I've been playing around with the Get Driving Directions sample and it seems to have some errors.  I was attempting to find directions between some local addresses and Firebug was constantly spitting out the following error: "TypeError: err.details is undefined".  This only happens when there are issues with the way the address is typed.  After playing around with it a bit, I've found that the format of your address has to be VERY specific; each element of the address MUST be separated by a comma or the map fails to find a route.  So "1600 Pennsylvania Avenue, Washington, DC, 20050" would be an appropriate address, but "1600 Pennsylvania Avenue Washington DC 20050" would not be (even dropping just one comma will cause the map to find an error).

This certainly compromises the usefulness of this tool.  Is this a network analyst problem or something with the code in the sample itself?
0 Kudos
3 Replies
MostafaFouly
New Contributor
Hi,

it's related to the code. As you can see below the input value is splitted by ',' So the address is the first part (
1600 Pennsylvania Avenue) then the City (Washington) the State (DC) and the Zip code (20050)

//Parse and geocode "from" address
var fromArr = dojo.byId("fromTxf").value.split(","),
fromAddress = { Address:fromArr[0], City:fromArr[1], State:fromArr[2], Zip:fromArr[3] };

grtz,
mostafa.
0 Kudos
BrettGreenfield__DNR_
Occasional Contributor II
Thanks for the response; I think I understand this a little bit more now.  But does this mean the values HAVE to be separated by a comma, or some other character?  This is a pretty large inconvenience, as an end user might not understand why they aren't receiving driving directions even though they are, in their mind, typing the address in correctly.  Frankly, this is not functionality that I would want my end-user to have to deal with.  Is there a way around this?  I know if I go to google maps I can type my address pretty much any way I choose and a route will be found.
0 Kudos
MostafaFouly
New Contributor
esri locator geocode server has the following params:
Address (Type: esriFieldTypeString, Alias: Address, Required: false )
City (Type: esriFieldTypeString, Alias: City, Required: false )
State (Type: esriFieldTypeString, Alias: State, Required: false )
Zip (Type: esriFieldTypeString, Alias: Zip, Required: false )

So they have to be filled in order to execute the locator service provided by esri
you can customize the locator though, check the following url:
http://resources.arcgis.com/gallery/file/geocoding/details?entryID=51EE55F8-1422-2418-7F8B-FD82DE958...
but to be honest i never tried it before.

the user can be notified by your format using a label beside the textbox like this esri sample:
http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/demos/locator/locator_address...

you can also handle it programmatically by checking the input string at the client side before executing the locator task

last option will be splitting the address in different textboxes to be noticed easier, i don't recommend it though.
0 Kudos