0

I'd like to use the Search widget to search for addresses and intersections in a custom web app (JS v3.31). Is there any way to restrict this search to a particular city?

I see how to restrict it to a specified extent, but this is not good enough for us; our basemaps are made only for the city borders, and any extent will include some areas outside of our map. (This question also post on Geonet , with no responses)

2 Answers 2

1

I do not see that as one of the options for the Search widget. If it truly is not an option in the OOTB widget, you can always write your own widget - use an HTML text box, maybe an autocomplete library like jQuery UI Autocomplete, and wire it up to use the Locator task, and after you get the results do your additional geometry filter using the Geometry Engine.

1
  • thanks - i was able to use the geocoder REST API and append the city to the singleLine parameter, seems to work...I haven't yet figured out how to populate a dropdown with the suggestions, but Ill look at using JQuery as you suggest.
    – JasonBK
    Commented Feb 21, 2020 at 21:20
1

If you specify the source(s) for the Search widget, you can specify a "suffix" (and "prefix") that will add a certain string. This should work ok as long as your users only type in the address and doesn't add city/zip etc.

https://developers.arcgis.com/javascript/3/jsapi/search-amd.html#sources

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.