<?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 PopupTemplate's content method called only once per feature in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popuptemplate-s-content-method-called-only-once/m-p/96429#M8850</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using Esri maps inside an Angular app, and I am rendering my popups as Angular components with data published from the &lt;CODE&gt;PopupTemplate&lt;/CODE&gt;'s &lt;CODE&gt;content&lt;/CODE&gt; method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;layer.popupTemplate = new PopupTemplate({
&amp;nbsp;&amp;nbsp;content: (feature: { graphic: __esri.Graphic }) =&amp;gt; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.publishPopupData(layer, feature.graphic.attributes);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return popupComponent.viewContainerRef.element.nativeElement;
&amp;nbsp;&amp;nbsp;},
&amp;nbsp;&amp;nbsp;// other properties... 
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works well, except in the case where there are multiple features at a given point. When the user cycles through the features, if he/she returns to a feature that was already displayed, the content method does not execute, so the popup data is not published.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can access the currently selected feature on the MapView's popup, but I need to know what layer the feature came from in order to publish the data properly (each layer has unique requirements for processing the ArcGIS data into the models used by the popups).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mapView.popup.watch('selectedFeature', (graphic: __esri.Graphic) =&amp;gt; {
&amp;nbsp;&amp;nbsp;const layer = ???;
&amp;nbsp;&amp;nbsp;this.publishPopupData(layer, graphic.attributes);
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nominally, &lt;CODE&gt;graphic.layer&lt;/CODE&gt; should contain the layer reference, but in my case it is always &lt;CODE&gt;null&lt;/CODE&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to force the popups to always call the &lt;CODE&gt;content&lt;/CODE&gt; method, even if it was already executed for a given feature?&amp;nbsp;Alternatively, is there a way to get the layer a feature belongs to from &lt;CODE&gt;MapView.popup&lt;/CODE&gt; (or something else I have not considered)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it matters, the popups are for &lt;CODE&gt;MapImageLayer&lt;/CODE&gt; sublayers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:00:58 GMT</pubDate>
    <dc:creator>AndrewGallant</dc:creator>
    <dc:date>2021-12-12T16:00:58Z</dc:date>
    <item>
      <title>PopupTemplate's content method called only once per feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popuptemplate-s-content-method-called-only-once/m-p/96429#M8850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using Esri maps inside an Angular app, and I am rendering my popups as Angular components with data published from the &lt;CODE&gt;PopupTemplate&lt;/CODE&gt;'s &lt;CODE&gt;content&lt;/CODE&gt; method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;layer.popupTemplate = new PopupTemplate({
&amp;nbsp;&amp;nbsp;content: (feature: { graphic: __esri.Graphic }) =&amp;gt; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.publishPopupData(layer, feature.graphic.attributes);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return popupComponent.viewContainerRef.element.nativeElement;
&amp;nbsp;&amp;nbsp;},
&amp;nbsp;&amp;nbsp;// other properties... 
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works well, except in the case where there are multiple features at a given point. When the user cycles through the features, if he/she returns to a feature that was already displayed, the content method does not execute, so the popup data is not published.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can access the currently selected feature on the MapView's popup, but I need to know what layer the feature came from in order to publish the data properly (each layer has unique requirements for processing the ArcGIS data into the models used by the popups).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mapView.popup.watch('selectedFeature', (graphic: __esri.Graphic) =&amp;gt; {
&amp;nbsp;&amp;nbsp;const layer = ???;
&amp;nbsp;&amp;nbsp;this.publishPopupData(layer, graphic.attributes);
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nominally, &lt;CODE&gt;graphic.layer&lt;/CODE&gt; should contain the layer reference, but in my case it is always &lt;CODE&gt;null&lt;/CODE&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to force the popups to always call the &lt;CODE&gt;content&lt;/CODE&gt; method, even if it was already executed for a given feature?&amp;nbsp;Alternatively, is there a way to get the layer a feature belongs to from &lt;CODE&gt;MapView.popup&lt;/CODE&gt; (or something else I have not considered)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it matters, the popups are for &lt;CODE&gt;MapImageLayer&lt;/CODE&gt; sublayers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:00:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popuptemplate-s-content-method-called-only-once/m-p/96429#M8850</guid>
      <dc:creator>AndrewGallant</dc:creator>
      <dc:date>2021-12-12T16:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: PopupTemplate's content method called only once per feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popuptemplate-s-content-method-called-only-once/m-p/96430#M8851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm having the exact same issue. Did you ever come across a solution?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2018 11:00:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popuptemplate-s-content-method-called-only-once/m-p/96430#M8851</guid>
      <dc:creator>KevinHaeni</dc:creator>
      <dc:date>2018-11-15T11:00:37Z</dc:date>
    </item>
  </channel>
</rss>

