<?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 How to clear Geocoder results from a different widget in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527550#M13795</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Within the Geocoder Widget.js file, _initGeocoder function, if I add the following line: &lt;/P&gt;&lt;P&gt;this.own(on(geocoder, "clear", lang.hitch(this, "clearResults")));&lt;/P&gt;&lt;P&gt;and then add the corresponding "clearResults" function, I am able to clear the map of any graphic selection and/or popup.&amp;nbsp; However, I want to accomplish this task within another widget and not modify the original geocoder widget.&amp;nbsp; Within my other widget, I know I need to use aspect but not quite sure if I should use .before or .after.&amp;nbsp; I think .before makes more sense, but I'm not clear how to incorporate the line of code above into the _initGeocoder function and then call the clearResults function from within my widget.&amp;nbsp; This seems like an easy task but I can't seem to get the syntax right.&amp;nbsp; Any help/thoughts would be great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Feb 2015 22:47:17 GMT</pubDate>
    <dc:creator>DouglasGuess</dc:creator>
    <dc:date>2015-02-25T22:47:17Z</dc:date>
    <item>
      <title>How to clear Geocoder results from a different widget</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527550#M13795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Within the Geocoder Widget.js file, _initGeocoder function, if I add the following line: &lt;/P&gt;&lt;P&gt;this.own(on(geocoder, "clear", lang.hitch(this, "clearResults")));&lt;/P&gt;&lt;P&gt;and then add the corresponding "clearResults" function, I am able to clear the map of any graphic selection and/or popup.&amp;nbsp; However, I want to accomplish this task within another widget and not modify the original geocoder widget.&amp;nbsp; Within my other widget, I know I need to use aspect but not quite sure if I should use .before or .after.&amp;nbsp; I think .before makes more sense, but I'm not clear how to incorporate the line of code above into the _initGeocoder function and then call the clearResults function from within my widget.&amp;nbsp; This seems like an easy task but I can't seem to get the syntax right.&amp;nbsp; Any help/thoughts would be great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 22:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527550#M13795</guid>
      <dc:creator>DouglasGuess</dc:creator>
      <dc:date>2015-02-25T22:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to clear Geocoder results from a different widget</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527551#M13796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Doug,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem with this approach is that the Geocoder Widget starts automatically and you can't get access to the _initGeocoder() function before it has run.&amp;nbsp; I noticed the findComplete function runs with every find, so you could do it this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;aspect.after(widget, 'findComplete', lang.hitch(this, function(response) {
&amp;nbsp; if (!this.geocoderAltered) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geocoderAltered = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; widget.own(on(response.target, 'clear', lang.hitch(this, 'clearResults')));
&amp;nbsp; }
}), true);
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tested this and it seems to work,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:58:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527551#M13796</guid>
      <dc:creator>LarryStout</dc:creator>
      <dc:date>2021-12-11T22:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to clear Geocoder results from a different widget</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527552#M13797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Douglas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The way I would do it is use dojo query to get the widgets dom not and then use registry to get the dijit from the dom node.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is code that you can run from another widget to get to the geocoder:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var domId = query('.jimu-widget-geocoder');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var geocodeId = domAttr.get(domId[0], 'id');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var geocoderWidget = registry.byId(geocodeId);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //console.info(geocoderWidget);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var geocoder = registry.byId(domAttr.get(geocoderWidget.domNode.children[0],'id'));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //console.info(geocoder);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on(geocoder, 'clear', lang.hitch(this, 'clearResults'));&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course if you have your geocoder widget configured to use more than one geocode service then you will need to grab the next child.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var geocoder2 = registry.byId(domAttr.get(geocoderWidget.domNode.children[1],'id'));&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:58:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527552#M13797</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T22:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to clear Geocoder results from a different widget</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527553#M13798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert and Larry for your input.&amp;nbsp; I tested both methods and they both work, but decided to use Robert's.&amp;nbsp; It seemed like it was a cleaner approach to access the geocoder widget.&amp;nbsp; Thanks again guys!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 14:34:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527553#M13798</guid>
      <dc:creator>DouglasGuess</dc:creator>
      <dc:date>2015-02-26T14:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to clear Geocoder results from a different widget</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527554#M13799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like Robert's approach better also.&amp;nbsp; I was curious about using multiple geocoders, and did some testing.&amp;nbsp; It seems the active geocoder is always geocoderWidget.domNode.children[&lt;SPAN class="number"&gt;0], and there never is a geocoderWidget.domNode.children[1&lt;SPAN class="number"&gt;].&amp;nbsp; Furthermore, the event listener assigned to geocoderWidget.domNode.children[&lt;SPAN class="number"&gt;0] seems to transfer to any active geocoder.&amp;nbsp; Strange.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="number"&gt;&lt;SPAN class="number"&gt;&lt;SPAN class="number"&gt;Here's a variant on Robert's approach that I tested with two geocoders:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;query('.jimu-widget-geocoder &amp;gt; .simpleGeocoder').forEach(lang.hitch(this, function(node) {
&amp;nbsp; var geocoder = registry.byId(node.id);
&amp;nbsp; on(geocoder, 'clear', lang.hitch(this, 'clearResults'));
}));
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The forEach() construct implies multiple objects will be returned, but in fact, only one is ever returned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527554#M13799</guid>
      <dc:creator>LarryStout</dc:creator>
      <dc:date>2021-12-11T22:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to clear Geocoder results from a different widget</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527555#M13800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Larry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Nice, I knew the code could be optimized.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 17:39:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-to-clear-geocoder-results-from-a-different/m-p/527555#M13800</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-02-26T17:39:15Z</dc:date>
    </item>
  </channel>
</rss>

