Directions widget

2457
4
06-19-2014 11:12 AM
robertbowman
New Contributor
I am attempting to use this widget with a local GeocoderServer. I can create the Geocoder and specify the URL, setting arcgisGeocoder to false, and the Geocoder works fine.

I can also set the routeTaskUrl in the Directions constructor to the local NA service and it is used. However trying

    var geocoderList = [];
    geocoderList.push(geocoder);

    var directions = new Directions({
     map : map,
     geocoders : geocoderList,
                                        .....

still results in a call to

geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer

While the World GeocodeServer does return a result, the values are not compatible with the local NA server. Is there any way to override the Directions widget geocoder?
0 Kudos
4 Replies
MattDriscoll
Esri Contributor
Hi Robert,

Yes, you should be able to set the geocoderOptions on the constructor parameters with a default of Geocoder settings. They can be these settings:

https://developers.arcgis.com/javascript/jsapi/geocoder-amd.html#geocoder1

I believe that geocoders on the directions widget is just a property.

Let me know if that works.

Thanks
0 Kudos
robertbowman
New Contributor
Hi Robert,

Yes, you should be able to set the geocoderOptions on the constructor parameters with a default of Geocoder settings. They can be these settings:

https://developers.arcgis.com/javascript/jsapi/geocoder-amd.html#geocoder1

I believe that geocoders on the directions widget is just a property.

Let me know if that works.

Thanks


Matt,

Thanks, that worked.  The geocoderOptions versus geocoders in the parameters is a little confusing. I didn't see how a Geocoder[] would work since they are already tied to a node.
0 Kudos
williamcarr
Occasional Contributor II

Robert,

     Could you post an example of how you set this up?

Thanks

0 Kudos
robertbowman
New Contributor

Sorry about the delay.

For development purposes, we were geocoding on one machine and routing on another but it certainly works if both services are on the same machine.

   var locatorURL =
   "http://geocodeserver:6080/arcgis/rest/services/address_comp/GeocodeServer";
   var routeURL =
   "http://routeserver:6080/arcgis/rest/services/route_service/NAServer/Route";

                sr = new SpatialReference(4326);

                var directionsOptions = {

                    arcgisGeocoder : false,

                    geocoders :[{

                            url : locatorURL,

                            singleLineFieldName: "SingleLine",

                            name: "Logisys Geocoder",

                            outSpatialReference : sr,

                            wkid : wkid,

                            outFields : "Loc_name"}]

                };

                rp = new RouteParameters();

                rp.outSpatialReference = {"wkid":wkid};

                rp.returnRoutes = false;

                rp.returnDirections = true;

                var directions = new Directions({

                    map : map,

                    geocoderOptions : directionsOptions,

                    routeTaskUrl : routeURL,

                    routeParameters : rp,

                    directionsLengthUnits : Units.MILES

                    }, "directions");

               

                directions.startup();

0 Kudos