HOW TO
The results of the Search widget can be limited to a certain extent in Web AppBuilder for ArcGIS by editing the config_Search.json file in [install dir]\server\[app#]\configs, and the Widget.js file in [install Dir]\server\apps\[app #]\widgets\Search.
The following code segments demonstrate how to limit the results of the Search widget to a specific extent.
Add the searchExtent variables, consisting of the minimum and maximum x- and y- coordinates, as follows:
"type": "locator", "searchExtent": { "xmin": -9589858.361942431, "ymin": 3964964.109405532, "xmax": -9522593.777051566, "ymax": 4031693.635098401, "spatialReference": { "wkid": 102100 } }
Following the code above, Extent is now required in the require list in the beginning of the script.
require([ ... 'esri/geometry/Extent', ... ], function()
The variables added in the config_Search.json file are then retrieved in the Widget.js file in [install Dir]\server\apps\[app #]\widgets\Search to create a new Extent object, referring to the minimum and maximum x- and y- coordinates set in the config_Search.json file.
if (source && source.url && source.type === 'locator') { locator: new Locator(source.url || ""), outFields: ["*"], singleLineFieldName: source.singleLineFieldName || "", name: source.name || "", placeholder: source.placeholder || "", countryCode: source.countryCode || "", maxResults: source.maxResults || 6 }; if(source.searchExtent){ locSource.searchExtent = new Extent(source.searchExtent); } return locSource; }
Get help from ArcGIS experts
Download the Esri Support App