Web AppBuilder Directions not working with local Geocoder

2678
13
09-26-2016 07:38 AM
JeffPace
MVP Alum

I am trying to configure the directions widget in the WAB.  Works fine with locally hosted services.  When I switch the geocoder to a locally hosted one, it stops working

1. Locations are returning coordinates instead of addresses, even though an address is returned in firebug (same as Defect ID: BUG-000084635 which was marked as fixed but does not appear to be)

2. Locations are then greyed out and "Unable to route to these addresses"

Any ideas?

khutchins-esristaff

Tags (1)
0 Kudos
13 Replies
KellyHutchins
Esri Frequent Contributor

I am not sure about the behavior with WAB. Have you tested with the directions widget sample in the JSAPI? That might help rule out any WAB specific behavior. 

Directions | ArcGIS API for JavaScript 3.18 

0 Kudos
JeffPace
MVP Alum

So I just tried this in Web App Builder 2.4 and its showing coordinates again instead of an address, even though an address is returning in the json response.

For example, the reverse geocoder on clicking the map returns

https://www.mymanatee.org/arcgis01/rest/services/tools/AGSParcel/GeocodeServer/reverseGeocode?outSR=... 

{"address":{"Street":"717 30TH ST W","City":"BRADENTON","ZIP":"34205"},"location":{"x":-9194031.2255866416,"y":3185221.8084431593,"spatialReference":{"wkid":102100,"latestWkid":3857}}}

But the directions widget displays


Any ideas? or anyone you can forward this to?

0 Kudos
KellyHutchins
Esri Frequent Contributor

Can you repro this with the latest version of the JSAPI and the directions widget outside the WAB? If not maybe post in theWeb AppBuilder for ArcGIS‌  place

JeffPace
MVP Alum

Yes it fails at 3.20 also outside WAB.

The problem is the geocoder/locator.  If you use the ESRI world locator it works.  If you use a local locator, it does not

var sources =[
{
// locator: new Locator("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),
locator: new Locator("https://www.mymanatee.org/accela/rest/services/tools/ParcelGeocode/GeocodeServer"),
singleLineFieldName: "SingleLine",
outFields: ["Addr_type"],
localSearchOptions: {
minScale: 300000,
distance: 50000
}

}
];
var options = {
sources: sources
};
//default will point to ArcGIS world routing service
var directions = new Directions({
map: map,
showClearButton:true,
showSegmentPopup:false,
directionsLengthUnits:"esriMiles",
geometryTaskUrl:"https://www.mymanatee.org/arcgis01/rest/services/Utilities/Geometry/GeometryServer",
mapClickActive:true,
routeTaskUrl: "https://www.mymanatee.org/arcgis02/rest/services/routing/routing/NAServer/Route",
searchOptions:options

},"dir");
directions.startup();

JS Bin - Collaborative JavaScript Debugging 

If you change the locator back and forth you can replicate the issue.  

0 Kudos
KellyHutchins
Esri Frequent Contributor

Thanks Jeff I was able to reproduce the issue with your code and I'm checking with the developers. It looks like they added a new source property when they fixed this bug that you need to set in order for the address to display with your custom service. The property is called locationToAddressTemplate and is used during the reverse geocode operation. So you'll want to add this to your app code. 

       var sources =[{
          locator: new Locator("https://www.mymanatee.org/accela/rest/services/tools/ParcelGeocode/GeocodeServer"),
          locationToAddressTemplate: "${Street}, ${City}, ${ZIP}",
          singleLineFieldName: "SingleLine",
          outFields: ["Addr_type"],
          localSearchOptions: {
            minScale: 300000,
            distance: 50000
          }
        }];

However even after adding it I see the reverse geocode happen but the address isn't updated in the input boxes.  I'll reply back here with more info once I hear back from the developers. 

JeffPace
MVP Alum

Thank you, also please let the WAB team know, as i cant add properties there.  

0 Kudos
benchikh
New Contributor III

Hi I know that is an OLD  question, but actually Im facing the same error I cannot work with my own Geocoder Service but it'is OK with the ESRI Geocoder!

Could you please let me know if you have solved the issue, knowing that Im working with arcgis API 3.38,Many thanks

0 Kudos
JeffPace
MVP Alum

I am not seeing that issue any longer

https://jsbin.com/pubimubeqa/edit?html,output

benchikh
New Contributor III

Many thanks,

I have another question please, could you  help me to get all the directions result routes infos from the directions as I need to send them via a web Service... so if you have an idea how can I do it please just update your above code  with some steps to do..."I know that there is "directions-finish" event, but Im not able to figure it out.

0 Kudos