<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Choosing a search source based on searchTerm? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/choosing-a-search-source-based-on-searchterm/m-p/1599030#M86751</link>
    <description>&lt;P&gt;I want to use my "&lt;SPAN&gt;Assessor Identification Numbers" search source if isAIN(searchTerm) returns true.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Mar 2025 15:30:36 GMT</pubDate>
    <dc:creator>BrianTrang</dc:creator>
    <dc:date>2025-03-25T15:30:36Z</dc:date>
    <item>
      <title>Choosing a search source based on searchTerm?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/choosing-a-search-source-based-on-searchterm/m-p/1599028#M86750</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;import Search from "@arcgis/core/widgets/Search";&lt;BR /&gt;import LocatorSearchSource from "@arcgis/core/widgets/Search/LocatorSearchSource";&lt;BR /&gt;import LayerSearchSource from "@arcgis/core/widgets/Search/LayerSearchSource";&lt;BR /&gt;import FeatureLayer from "@arcgis/core/layers/FeatureLayer";&lt;/P&gt;&lt;P&gt;const isAIN = (searchTerm) =&amp;gt; {&lt;BR /&gt;return /^\d{10}$/.test(searchTerm); // Adjust this regex if needed&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;const searchWidget = new Search({&lt;BR /&gt;view: mapView,&lt;BR /&gt;includeDefaultSources: false,&lt;BR /&gt;searchAllEnabled: false, // Disable searching across all sources by default&lt;BR /&gt;sources: [&lt;BR /&gt;new LocatorSearchSource({&lt;BR /&gt;url: &amp;lt;myurl&amp;gt;,&lt;BR /&gt;name: "A County CAMS",&lt;BR /&gt;placeholder: "Find address",&lt;BR /&gt;resultSymbol: resultSymbol,&lt;BR /&gt;singleLineFieldName: "SingleLine",&lt;BR /&gt;popupEnabled: false,&lt;BR /&gt;}),&lt;BR /&gt;new LocatorSearchSource({&lt;BR /&gt;url: "&lt;A href="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer" target="_blank"&gt;https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer&lt;/A&gt;",&lt;BR /&gt;name: "Esri World Geocoder",&lt;BR /&gt;placeholder: "Find address or place",&lt;BR /&gt;resultSymbol: resultSymbol,&lt;BR /&gt;singleLineFieldName: "SingleLine",&lt;BR /&gt;filter: searchExtent,&lt;BR /&gt;popupEnabled: false,&lt;BR /&gt;outFields: ["Addr_type"],&lt;BR /&gt;}),&lt;BR /&gt;new LayerSearchSource({&lt;BR /&gt;layer: new FeatureLayer({&lt;BR /&gt;url: &amp;lt;myurl&amp;gt;,&lt;BR /&gt;}),&lt;BR /&gt;name: "Assessor Identification Numbers",&lt;BR /&gt;placeholder: "Find AIN (ten digits)",&lt;BR /&gt;resultSymbol: props.toggle ? fillSymbol : resultSymbol,&lt;BR /&gt;popupEnabled: false,&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;searchFields: ["AIN", "APN"],&lt;BR /&gt;}),&lt;BR /&gt;],&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Intercept the search-start event&lt;BR /&gt;searchWidget.on("search-start", (event) =&amp;gt; {&lt;BR /&gt;if (isAIN(event.searchTerm)) {&lt;BR /&gt;searchWidget.activeSourceIndex = 2; // Set source to AIN layer&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Handle search complete to zoom to the found location&lt;BR /&gt;searchWidget.on("search-complete", (event) =&amp;gt; {&lt;BR /&gt;if (event.numResults &amp;gt; 0) {&lt;BR /&gt;const result = event.results[0].results[0]; // Get first result&lt;BR /&gt;if (result) {&lt;BR /&gt;mapView.goTo(result.feature.geometry); // Zoom to found location&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;mapView.ui.add(searchWidget, "top-right");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried a code snippet like above, however my mapView.goTo isn't going to the correct location.&amp;nbsp; I a, wondering if I am missing something?&lt;BR /&gt;&lt;BR /&gt;Would appreciate any tips. Thank you.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 25 Mar 2025 15:29:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/choosing-a-search-source-based-on-searchterm/m-p/1599028#M86750</guid>
      <dc:creator>BrianTrang</dc:creator>
      <dc:date>2025-03-25T15:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing a search source based on searchTerm?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/choosing-a-search-source-based-on-searchterm/m-p/1599030#M86751</link>
      <description>&lt;P&gt;I want to use my "&lt;SPAN&gt;Assessor Identification Numbers" search source if isAIN(searchTerm) returns true.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 15:30:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/choosing-a-search-source-based-on-searchterm/m-p/1599030#M86751</guid>
      <dc:creator>BrianTrang</dc:creator>
      <dc:date>2025-03-25T15:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing a search source based on searchTerm?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/choosing-a-search-source-based-on-searchterm/m-p/1599041#M86752</link>
      <description>&lt;P&gt;I've been getting the following error "&lt;SPAN&gt;Goto was interrupted", so I am guessing I need a way to await the goTo? I been trying to pass the extent to goTo.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 15:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/choosing-a-search-source-based-on-searchterm/m-p/1599041#M86752</guid>
      <dc:creator>BrianTrang</dc:creator>
      <dc:date>2025-03-25T15:43:27Z</dc:date>
    </item>
  </channel>
</rss>

