Search widget by Suburb/neighborhood only (API 4x)

555
5
Jump to solution
01-05-2022 12:52 AM
ZA1
by
New Contributor III

Hi

I would like to create a search widget which only searches by suburb/ neighborhood

Thus, only suburb names are provided as suggestions in the search. 

 

I think that this might require some configuration in sources. However, I cannot find the solution.

Thanks in advance 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

Yes, Neighborhood is there in the Address Fields, but that is for multiline input, and that doesn't mean you can search on them from the Search widget. There are 2 input types for geocoding: multiline and singleline. The Search widget only uses singleline, and suggestions only work with singleline anyway.

For this to work with the Search widget, you would need to publish or configure a custom locator service. I would suggest that you use the Create Locator tool in ArcGIS Pro with the “Neighborhood” role. Here is more information on that process: 

https://pro.arcgis.com/en/pro-app/latest/help/data/geocoding/introduction-to-custom-locators.htm

You could also use the locator class and build your own UI, instead of using the Search widget. Here is a tutorial that walks you through the basics:

https://developers.arcgis.com/javascript/latest/find-places/

Unfortunately, I think these are your available options. There might be a clever way to overwrite the getResults() and getSuggestions() methods, but I don't know for sure if this would work.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-LocatorSearchSourc...

View solution in original post

5 Replies
ReneRubalcava
Frequent Contributor

You would need to publish a Locator service specific for what you need.

Noah-Sager
Esri Regular Contributor
0 Kudos
ZA1
by
New Contributor III

Hi thanks for the responses @ReneRubalcava @@Noah-Sager 

By this do you mean a Geocode Server that only contains suburbs?

 

The geocode server that I use contains all address information, including suburb (neighborhood)

I just need to find some way of querying only Suburb data: 

ZA1_0-1641451475958.png

Any ideas how to do this? 

Thanks

0 Kudos
Noah-Sager
Esri Regular Contributor

Yes, Neighborhood is there in the Address Fields, but that is for multiline input, and that doesn't mean you can search on them from the Search widget. There are 2 input types for geocoding: multiline and singleline. The Search widget only uses singleline, and suggestions only work with singleline anyway.

For this to work with the Search widget, you would need to publish or configure a custom locator service. I would suggest that you use the Create Locator tool in ArcGIS Pro with the “Neighborhood” role. Here is more information on that process: 

https://pro.arcgis.com/en/pro-app/latest/help/data/geocoding/introduction-to-custom-locators.htm

You could also use the locator class and build your own UI, instead of using the Search widget. Here is a tutorial that walks you through the basics:

https://developers.arcgis.com/javascript/latest/find-places/

Unfortunately, I think these are your available options. There might be a clever way to overwrite the getResults() and getSuggestions() methods, but I don't know for sure if this would work.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-LocatorSearchSourc...

ZA1
by
New Contributor III

Thanks for the detailed and clear explanation @Noah-Sager. Appreciated. I will try to find some way of achieving what I need and provide updates here if I do succeed.