Select to view content in your preferred language

Search Widget set searchExtent

5726
4
Jump to solution
05-07-2015 11:11 AM
JeffMitzelfelt
Regular Contributor

I would like to set the searchExtent for the default Locator  for the search widget, but I don't see an obvious way to do that.

I have successfully limited the search using the following code:

var searchExtent = new Extent({
     xmin: -91.5,
     ymin: 37,
     xmax: -87.5,
     ymax: 42.5,
     spatialReference: {
          wkid: 4326
     }
});

var search = new Search({map: map}, "searchDiv");

search.sources[0].searchExtent = searchExtent;
search.startup()

Am I missing something?

Has anyone seen a better way to do this?

1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

The approach you are currently using is a valid approach for setting the search extent for the default locator.  You could check the name of the locator before setting the search extent to ensure its the Esri World Locator but if you haven't modified the widget's sources the first one in the sources array will be the default (Esri World Locator).

View solution in original post

4 Replies
KellyHutchins
Esri Frequent Contributor

The approach you are currently using is a valid approach for setting the search extent for the default locator.  You could check the name of the locator before setting the search extent to ensure its the Esri World Locator but if you haven't modified the widget's sources the first one in the sources array will be the default (Esri World Locator).

JeffMitzelfelt
Regular Contributor

Thanks, Kelly.

0 Kudos
DaveOrlando
Frequent Contributor

Hello,

I'm coming from Silverlight land and am behind the learning curve again (rebuilding our current application).

I've been using the Web AppBuilder and examining the downloaded code to add such customizations as above, but I'm getting quite lost. Could you let me know where to put the code above. I though maybe in the Direction's Widget.js around the SearchOptions, Line 192 but it is breaking the widget.

Thanks for any help you can give.

Dave

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Dave,

  When you have questions about WAB then you would be better off posting those in the Web AppBuilder for ArcGIS​ space. But to answer your question the adding the searchExtent to a source in the Search Widget (not directions widget as you were looking at) is as simple as adding the extent json to the[install dir]\server\apps\[app#]\configs\Search\config_Search.json

Here is an example:

   {
      "layerId": null,
      "url": "your url",
      "name": "Owner Parcels",
      "placeholder": "Calhoun Parcels",
      "searchFields": [
        "PPIN"
      ],
      "searchExtent": {
        "xmin": -9589751.5926,
        "ymin": 3969370.735299997,
        "xmax": -9521083.0409,
        "ymax": 4024577.6668,
        "spatialReference": {
         "wkid": 102100
        }
      },
      "displayField": "NAME",
      "exactMatch": true,
      "maxResults": 6,
      "type": "query"
    }