HOW TO

Limit the results of the Search widget to a specific extent in Web AppBuilder for ArcGIS

Last Published: April 25, 2020

Summary

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.

Procedure

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; 
          }

Article ID: 000014969

Software:
  • ArcGIS API for JavaScript 4 x
  • ArcGIS Web AppBuilder
  • ArcGIS API for JavaScript 3 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options