locator = new esri.tasks.Locator("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_EU/GeocodeServer");
routeTask = new esri.tasks.RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_EU/NAServer/Route");
//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] }; locator.addressToLocations(fromAddress, ["Loc_name"], function(addressCandidates) { configureRoute(addressCandidates, "from"); }); //Parse and geocode "to" address var toArr = dojo.byId("toTxf").value.split(","), toAddress = { Address:toArr[0], City:toArr[1], State:toArr[2], Zip:toArr[3] }; locator.addressToLocations(toAddress, ["Loc_name"], function(addressCandidates) { configureRoute(addressCandidates, "to"); }); }
tereshenkov;103217 wrote:
Heming,
<input type="text" id="fromTxf" value="1 Kungsgatan, Stockholm, 11143, Sweden" size="30" /> <input type="text" id="toTxf" value="10 Parkvagen, Gavle, 80267, Sweden" size="30" />
Heming,
Thank you very much for your help, I appreciate this. I have got the "from" point geocoded now and zoomed to on the map, but it seems that driving directions do not work properly yet.
Please see the code page with the address modified in the input text boxes (I have not changed anything apart from the input addresses):<input type="text" id="fromTxf" value="1 Kungsgatan, Stockholm, 11143, Sweden" size="30" /> <input type="text" id="toTxf" value="10 Parkvagen, Gavle, 80267, Sweden" size="30" />
The application treats the input start point to be the end point as well, so I do not get any route calculated, since the start and the end point coincide.
I have looked into the syntax and did not find any typo or alike, so my guess is that it has something to do with the syntax. I know that it is very hard to debug the JavaScript code (you get Intellisense in Aptana and that is basically it), but I would be beholden to you if you could take a look at the code when you get a chance.
Hi Heming,
Thank you very much for the help! Now it works as required. The only thing that is left is to figure out how the routing can work based on the address and not only on the postcode. I guess you have not noticed that if you choose to route between addresses with the same postcode, the route is not calculated.
You might try to enter as an input and an output points the addresses below:
20 Parkvagen, Gavle, 80267, Sweden
and
1 Parkvagen, Gavle, 80267, Sweden
As you'd see in the Directions window, the route starts at 80267 and ends at 80267. That is, the solver does not parse the addresses properly.
If you could take a look at this problem, I would really appreciate this. But, again, this is not a big deal, that is still good enough for testing purposes.
Thank you again for the help, Heming, much appreciated.