I've noticed that there is no searchExtent for the search widget source in 4.9. How can I further limit the search area more than countryCode in the Search widget? I'm trying to limit the search to a specific county/state.
Shakil,
You can filter the search source by a geometry.
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-FeatureLayerSearchSource.html#filter
Are there any examples of use? I can't seem to find any. Many thanks.
None that I have found.
Here is an example of using the where property of the filter:
<SPAN class="punctuation token">{</SPAN> featureLayer<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fservices.arcgis.com%2FV6ZHFr6zdgNZuVG0%2Farcgis%2Frest%2Fservices%2FUS_Senators%2FFeatureServer%2F0" target="_blank">https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> popupTemplate<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// autocasts as new PopupTemplate()</SPAN> title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"<a href={Web_Page} target='_blank'> {Name}</a>, ({Party}-{State}) "</SPAN><SPAN class="punctuation token">,</SPAN> overwriteActions<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">true</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> searchFields<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Name"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Party"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> suggestionTemplate<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"{Name}, Party: {Party}"</SPAN><SPAN class="punctuation token">,</SPAN> exactMatch<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN> outFields<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> placeholder<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"example: Casey"</SPAN><SPAN class="punctuation token">,</SPAN> name<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Senators"</SPAN><SPAN class="punctuation token">,</SPAN> zoomScale<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">500000</SPAN><SPAN class="punctuation token">,</SPAN> resultSymbol<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> type<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"picture-marker"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="comment token">// autocasts as new PictureMarkerSymbol()</SPAN> url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"images/senate.png"</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">36</SPAN><SPAN class="punctuation token">,</SPAN> width<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">36</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> filter<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> where<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"State = 'AL'"</SPAN><SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thanks again Robert. Do you know how I can find field names for the geocode servr I'm using? (https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer) I can't seem to find the list of fields.
It doesn't seem to have any effect. Here is my code:
var searchWidget = new Search({ view: view, includeDefaultSources:false, locationEnabled: false,
sources: [{ locator: new Locator({ url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"}), countryCode:"GB", categories:["Address", "Postal"], singleLineFieldName: "SingleLine", localSearchOptions: { minScale: 300000, distance: 50000 }, maxResults: 10, maxSuggestions: 10, suggestionsEnabled: true, minSuggestCharacters: 4, placeholder:"Find address", filter:{ where: "CITY = 'Maidstone'" } }]
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.