4.9 Search Widget: limit search results to state/county?

1541
7
10-05-2018 01:38 AM
ShakilChoudhury
New Contributor III

I've noticed that there is no searchExtent for the search widget source in 4.9. How can I further limit the search area more than countryCode in the Search widget? I'm trying to limit the search to a specific county/state.

Tags (1)
7 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
ShakilChoudhury
New Contributor III

Are there any examples of use? I can't seem to find any. Many thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

None that I have found.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Here is an example of using the where property of the filter:

        {
          featureLayer: {
            url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0",
            popupTemplate: { // autocasts as new PopupTemplate()
              title: "<a href={Web_Page} target='_blank'> {Name}</a>, ({Party}-{State}) ",
              overwriteActions: true
            }
          },
          searchFields: ["Name", "Party"],
          suggestionTemplate: "{Name}, Party: {Party}",
          exactMatch: false,
          outFields: ["*"],
          placeholder: "example: Casey",
          name: "Senators",
          zoomScale: 500000,
          resultSymbol: {
            type: "picture-marker", // autocasts as new PictureMarkerSymbol()
            url: "images/senate.png",
            height: 36,
            width: 36
          },
          filter: { where: "State = 'AL'"}
        }
0 Kudos
ShakilChoudhury
New Contributor III

Thanks again Robert. Do you know how I can find field names for the geocode servr I'm using? (https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer) I can't seem to find the list of fields.

0 Kudos
ShakilChoudhury
New Contributor III

It doesn't seem to have any effect. Here is my code:

    

var searchWidget = new Search({
view: view,
includeDefaultSources:false,
locationEnabled: false,

sources: [{
locator: new Locator({ url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"}),
countryCode:"GB",
categories:["Address", "Postal"],
singleLineFieldName: "SingleLine",
localSearchOptions: {
minScale: 300000,
distance: 50000
},
maxResults: 10,
maxSuggestions: 10,
suggestionsEnabled: true,
minSuggestCharacters: 4,
placeholder:"Find address",
filter:{
where: "CITY = 'Maidstone'"
}
}]

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

In your where it should be City not CITY the field name is case sensitive.

0 Kudos