3

I have built a tool that allows my users to perform geocode requests against the World Geocoding Service provided from Esri.

I would like to extend my tool to have an autocomplete feature, similar to how this can be achieved with the Autocomplete class from the Google Geocode API.

Although there is not a similar class available at the Esri service end, I was thinking that you could still hit the geocode service with a GET request, after listening for a slight delay after each keystroke from the end-user in something like a combo-box, and just return the top 5 results based on score.

I am looking for an answer that provides some code (can be pseudocode, or any language) on how to accomplish this, or if this workflow is even achievable. Something similar to this, but against the Esri Geocode service as opposed to map services.

1 Answer 1

5

Yes, you can autocomplete against a geocode service.

Pseudo-code:

if >4 chars + keystroke + delay 300ms
  Send Geocode request using text=inputBox.value

Here is how it looks at the front-end:

enter image description here

It waits for user to type in 4 characters, then populates a autocomplete flex component with the response.

When you choose an item from the dropdown, it zoom to the feature, and presents any additional results it found, using a green outline for high confident matches, and orange ones for lesser confident ones.

I have taken it a step further, and allowd the user to configure a bounding box, source country, state, and minimum candidate score within an XML file.

I need to tidy up some of the logic, and then I will try to put it into a flexviewer widget and upload to arcgis.com.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.