<?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 LayerInfos events in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867081#M12439</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to update the layers available for a custom widget. The layers needed are those in the layerList checked and I would like to update the information every&amp;nbsp; time the user check or uncheck a layer. I tried to use the LayerInfosObject and catch the layerInfosIsVisibleChanged or the layerInfosIsShowInMapChanged events, however I've observed a very weir behavior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to types of layers, those are in the webmap and those uploaded with the Add Data widget. For the layers included in the webmap it's fine, when I check or uncheck the layer an event is trigger.&amp;nbsp; The problem raise with the other layers where the number of events depends on the order when the layer was uploaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, the Webmap has two layers (A and B) and I added an three extra layers (C, D and E, in that order). When I update the visibility in the LayerList for the layer A or B, I can observe only one event. The same occurs with the layer C which was the first loaded. For the layer D, two events are triggered and three for the layer E.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code I use to test the event:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; startup: function() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.inherited(arguments);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('Demo::startup');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.counter = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; LayerInfos.getInstance(this.map, this.map.itemInfo).then(lang.hitch(this, function(layerInfosObject){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.layerInfosObject = layerInfosObject;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layerInfosObject.getLayerInfoArray().forEach(function(layerInfo) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;console.log(layerInfo.title, layerInfo.id);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;});&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.own(on(this.layerInfosObject, 'layerInfosIsVisibleChanged', &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; lang.hitch(this, function(){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; this.counter += 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; console.log(this.counter);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; })));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that normal?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Alfonso&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Jan 2018 21:11:39 GMT</pubDate>
    <dc:creator>AlfonsoYañez_Morillo</dc:creator>
    <dc:date>2018-01-17T21:11:39Z</dc:date>
    <item>
      <title>LayerInfos events</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867081#M12439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to update the layers available for a custom widget. The layers needed are those in the layerList checked and I would like to update the information every&amp;nbsp; time the user check or uncheck a layer. I tried to use the LayerInfosObject and catch the layerInfosIsVisibleChanged or the layerInfosIsShowInMapChanged events, however I've observed a very weir behavior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to types of layers, those are in the webmap and those uploaded with the Add Data widget. For the layers included in the webmap it's fine, when I check or uncheck the layer an event is trigger.&amp;nbsp; The problem raise with the other layers where the number of events depends on the order when the layer was uploaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, the Webmap has two layers (A and B) and I added an three extra layers (C, D and E, in that order). When I update the visibility in the LayerList for the layer A or B, I can observe only one event. The same occurs with the layer C which was the first loaded. For the layer D, two events are triggered and three for the layer E.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code I use to test the event:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; startup: function() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.inherited(arguments);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('Demo::startup');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.counter = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; LayerInfos.getInstance(this.map, this.map.itemInfo).then(lang.hitch(this, function(layerInfosObject){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.layerInfosObject = layerInfosObject;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layerInfosObject.getLayerInfoArray().forEach(function(layerInfo) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;console.log(layerInfo.title, layerInfo.id);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;});&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.own(on(this.layerInfosObject, 'layerInfosIsVisibleChanged', &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; lang.hitch(this, function(){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; this.counter += 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; console.log(this.counter);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; })));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that normal?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Alfonso&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jan 2018 21:11:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867081#M12439</guid>
      <dc:creator>AlfonsoYañez_Morillo</dc:creator>
      <dc:date>2018-01-17T21:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: LayerInfos events</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867082#M12440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Alfonso,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp;Sounds like the AddData widget is adding the "&lt;SPAN&gt;layerInfosIsVisibleChanged" event listener to each layer each time a layer is added, thus multiple events are being fired for each added layer.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jan 2018 21:54:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867082#M12440</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-01-17T21:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: LayerInfos events</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867083#M12441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is what I guessed, that there would be other listeners from somewhere .  Fortunately I could manage this issue, but I wonder if there is a way to discriminate the event from its listener, I mean, only catch the event triggered from an specific listener.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alfonso&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jan 2018 14:33:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867083#M12441</guid>
      <dc:creator>AlfonsoYañez_Morillo</dc:creator>
      <dc:date>2018-01-18T14:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: LayerInfos events</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867084#M12442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you looked at the contents of the event object that is passed to the listener function? It should have the layer in it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jan 2018 18:40:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867084#M12442</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-01-18T18:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: LayerInfos events</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867085#M12443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I have. The layers are in them, and they all are equal. What I did is to check some conditions to catch the first one and do nothing with the rest of the events.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jan 2018 21:46:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/layerinfos-events/m-p/867085#M12443</guid>
      <dc:creator>AlfonsoYañez_Morillo</dc:creator>
      <dc:date>2018-01-18T21:46:18Z</dc:date>
    </item>
  </channel>
</rss>

