Im looking to refine the search result only to minnesota state but i could not as its also filtering results from other state even after adding the filter statement

332
6
06-10-2020 08:19 PM
PriyankaRaja
New Contributor

this is my code kindly help me out 

//searchwidget start
const searchWidget = new Search({
view: view,
locationEnabled: true,
includeDefaultSources: false,
allPlaceholder: "Search Location...",
sources: [{
locator: new Locator({ url: "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"}),
countryCode:"US",
categories:["Address" ,"Postal"],
extent: {xmin:"-97.610790582999954", ymin:" 42.938855766000046", xmax:"-90.790790582999961", ymax:"49.758855766000039"},

"spatialReference": {
"wkid": 4326
},
singleLineFieldName: "SingleLine",
outFields: ["State", "Addr_type"],
suffix: ",Minnesota,MN,USA",
filter: {where: "State = 'Minnesota'"},
maxResults: 10,
maxSuggestions: 5,
suggestionsEnabled: true,
minSuggestCharacters: 4,
placeholder:"Find address"
}]
});

0 Kudos
6 Replies
Noah-Sager
Esri Regular Contributor

I'm not sure here, as I tested your code and it appears to work fine:

https://codepen.io/noash/pen/jOWMwEm 

Here are a couple resources I looked at, there are things I would change about your code, but I'm not sure that there is an issue here.

How To: Limit geocoding results to a specific area

How To: Limit geocoding results to a specific area 

World Geocoder for ArcGIS - FAQ

https://www.esri.com/~/media/Files/Pdfs/data/esri_data/pdfs/world-geocoder-faqs.pdf 

0 Kudos
PriyankaRaja
New Contributor

Thanks for the reply,

if you type wisconsin it will show results from wisconsin state that should not be the case what ever i type it should filter results only from minnesota state.

even i used the search-extent to specific rings am experiencing the same issue

Let me look into the other links which you have given 

0 Kudos
KenBuja
MVP Honored Contributor

However, when typing in places that you'd expect to see in Wisconsin (Madison, Milwaukee, etc), the widget only presents locations in Minnesota.

PriyankaRaja
New Contributor

yes its taking the suffix and displaying the result, there is no use of filter statement even if you hide the statement it is filtering result based on the suffix given, do we have any specific code for this issue??

0 Kudos
HarishPalaniappan
New Contributor III

Your View is not filtered. Try adding a view filter – some code examples are here
https://developers.arcgis.com/labs/javascript/filter-a-feature-layer/

0 Kudos
PriyankaRaja
New Contributor

Sure Will try that

0 Kudos