AnsweredAssumed Answered

How to test the result of a Locator for NO results?

Question asked by mbakerDPS on Jun 18, 2014
Latest reply on Jun 18, 2014 by mbakerDPS
All,

I'm having a hard time figuring out how to test a Locator (not a geocoder) for NO results.

Using evt.addresses.length, I can get the value of 0 for a Locator with no results.

However, when trying to test for no results in an IF/ELSE statement, I am not getting any response.

Here is the IF/ELSE statement I'm using:

if (evt.addresses.length > 0) {       alert('there were results');      }          else {            alert('there were no results');     }


When I test with my Locator, or the World Locator hosted by ESRI used in the sample below, I get no response in the ELSE statement.


To test this yourself:

- use the Sandbox for the "geocode an address" sample,

- In the javascript, below line 102 right below geom = candidate.location;, stick in the following:

alert('results: ' + evt.addresses.length);

- click the 'run' button

- type in a valid address - you should see the # of results pop up

- type in some gibberish, (the locator is good at finding a result for almost anything that ISN'T gibberish). You'll see the 'results: 0'

In the Firefox developer tools, this is what the result looks like:

[ATTACH=CONFIG]34699[/ATTACH]

Any thoughts?

Thank you!!!

Outcomes