How to restrict Search to a certain extent?

1885
2
Jump to solution
06-22-2017 09:37 AM
HemingZhu
Occasional Contributor III

I am replacing my GeoCoder  Widget with Search Widget. In GeoCoder i can restrict my search in a certain area by doing this:
arcgisGeocoder: true,
arcgisGeocoder: {
      placeholer: "Enter a US street address",
      searchExtent: new esri.geometry.Extent({
      xmin: -8631362.9367,
      ymin: 4655884.590300001,
      xmax: -8532954.2208,
      ymax: 4772527.9208,
      spatialReference: { "wkid": 102100 }
}),
url: "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
}

As i was looking into the search widget in JS 4.3, i could not find equivalent  options. Any ideas of how to set such options in Search Widget?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Hemming,

   You set the searchExtent on the Search widgets source array:

https://community.esri.com/thread/158365 

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Hemming,

   You set the searchExtent on the Search widgets source array:

https://community.esri.com/thread/158365 

HemingZhu
Occasional Contributor III

Sometime you just have to be patient and read through the doc. Yes, the is a property for sources array.

 Here is how i did and it worked.

this.geocoder = new Search({
container: "addrSearch",
autoSelect: false,
view: this.view,
searchAllEnabled: false,
sources: [
{
locator: new Locator("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),
singleLineFieldName: "SingleLine",
outFields: ["Addr_type"],
name: "World GeoCoding Service",
minSuggestCharacters: 3,
autoNavigate: false,
popupEnabled: false,
searchExtent: Extent({
xmin: -8631362.9367,
ymin: 4655884.590300001,
xmax: -8532954.2208,
ymax: 4772527.9208,
spatialReference: { "wkid": 102100 }
}),
placeholder: "Enter a US street address",
resultSymbol:null,
}
]
});

Thanks Robert.

0 Kudos