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.
Shakil,
You can filter the search source by a geometry.
Are there any examples of use? I can't seem to find any. Many thanks.
None that I have found.
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'"}
}
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.
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'"
}
}]
In your where it should be City not CITY the field name is case sensitive.