AnsweredAssumed Answered

Park Locator Template - GeoLocator distance parameter issue

Question asked by tiago.ribeiro.developer on Nov 6, 2015

Hello everyone.

 

I'll try to detail this issue the best I can.

 

I'm using this template to find sports facilities in Lisbon. When I use the routing functionality sometimes the end point is too far from the facility as you can see in this picture:

 

Using DevTools in Chrome I found out the problem in a reverseGeocode call:

 

Now I need to know the exact line where this is called. I searched...searched...and found it:

.../js/library/widgets/commonHelper/directionWidgetHelper.js

OK. Now what is the _esriDirectionsWidget?

At this point the "only" thing I need is to find how to change distance parameter. I searched a little bit in the JavaScript API and I found out this:

Directions | API Reference | ArcGIS API for JavaScript

where you can find a parameter called searchOptions that prior to 3.14 was named geocoderOptions (it doesn't refer that some options are not available in the past...)

Viewing the Search object there is a parameter called locationToAddressDistance

Search | API Reference | ArcGIS API for JavaScript

 

Perfect! I have a _esriDirectionsWidget.options.geocoderOptions in the code. I just need to add locationToAddressDistance parameter and it's done. No it isn't... The result was the same...

 

Then I tryed to move on to JS API v3.14. I got multiple errors but changing from _esriDirectionsWidget.options.geocoderOptions to _esriDirectionsWidget.options.searchOptions and adding locationToAddressDistance parameter this issue was solved. I got other multiple errors and preferred to revert to JS API v3.13.

 

Of course that I need to solve this issue for my client so I back to basics and downloaded the Directions.js file from JS API v3.13 and changed the value where is needed:

_reverseGeocodePoint:function(a,c){var b=new s;if(a&&this.get("activeGeocoder")){var k=c||a,r=this.get("activeGeocoder").distance||100;this._task.outSpatialReference=this._defaultSR;this.get("map")&&(this._task.outSpatialReference=this.get("map").spatialReference);this._task.locationToAddress(a,r,e.hitch(this,function(a){a={results:[this._hydrateResult(a)],geometry:k};this.onFindResults(a);b.resolve(a)}),

e.hitch(this,function(a){b.reject(a)}))}else b.reject("Geocoder:: no point or active geocoder defined");return b.promise}

 

Before fix this I tried multiple ways to override activeGeocoder object in Directions object but without success.

 

This post have three objectives:

1) Help people to solve if they have the same issue

2) Try to understand if someone had this issue and solve it in a cleaner way

3) Check if someone on Esri Inc side help me to understand if this is a bug, and if they pretend to solve it, or just a error from my side. and explain how to solve it.

 

Many thanks for any help from your side.

 

Best regards.

Outcomes