<?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: Programmatically open a popup template on a graphic in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1073340#M73659</link>
    <description>&lt;P&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Is this possible with a featurelayer content.&lt;/P&gt;&lt;P&gt;For example I'm trying to do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var districts = new FeatureLayer({
      url: "https:.../server/rest/services/Distritos_SNIT/MapServer/0",
      outFields: ["nom_cant", "nom_prov", "nom_distr","cod_prov","cod_distr","cod_canton"],
      renderer: renderer,
      labelingInfo: [labelClass],
      popupTemplate: {
        content: "&amp;lt;b&amp;gt;Provincia: &amp;lt;/b&amp;gt;{nom_prov} ({cod_prov})&amp;lt;br/&amp;gt; &amp;lt;b&amp;gt;Cantón:&amp;lt;/b&amp;gt; {nom_cant} ({cod_canton})&amp;lt;br/&amp;gt; &amp;lt;b&amp;gt;Distrito:&amp;lt;/b&amp;gt; {nom_distr} ({cod_distr})",
        title: "Ubicación del punto",
        location: { latitude: latwgs, longitude: lonwgs },

      }
    });
popup.open({
                title: "Esta es la ubicación de su punto",
                location: centerPoint,
                feature: [districts],
                content: "{nom_prov}"
            });​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I got the following error:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(index):119 [esri.core.Accessor] Accessor#set Assigning an instance of 'esri.layers.FeatureLayer' which is not a subclass of 'esri.Graphic'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thought ?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jun 2021 17:35:16 GMT</pubDate>
    <dc:creator>DiegoMonge_Chinchilla</dc:creator>
    <dc:date>2021-06-28T17:35:16Z</dc:date>
    <item>
      <title>Programmatically open a popup template on a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1007325#M71032</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In the API docs,&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content&lt;/A&gt;, it is mentioned that the pop up template is open using clicks by default. Is there a way to programmatically open a popup template on a graphics layer?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, the only available methods is to open up the pop up on a view.&amp;nbsp;&lt;/P&gt;&lt;P&gt;view.popup.open()&lt;/P&gt;&lt;P&gt;But what I am looking for is, say that I have graphicsLayer initialised as a feature layer&amp;nbsp;&lt;/P&gt;&lt;P&gt;graphicsLayer.graphics.getItemAt(x).popupTemplate.open()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 12:08:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1007325#M71032</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-12-07T12:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically open a popup template on a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1007346#M71033</link>
      <description>&lt;P&gt;You just use this line of code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.popup.open({
  features: graphics  // array of graphics or a single graphic in an array
});&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 07 Dec 2020 13:25:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1007346#M71033</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2020-12-07T13:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically open a popup template on a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1073340#M73659</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Is this possible with a featurelayer content.&lt;/P&gt;&lt;P&gt;For example I'm trying to do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var districts = new FeatureLayer({
      url: "https:.../server/rest/services/Distritos_SNIT/MapServer/0",
      outFields: ["nom_cant", "nom_prov", "nom_distr","cod_prov","cod_distr","cod_canton"],
      renderer: renderer,
      labelingInfo: [labelClass],
      popupTemplate: {
        content: "&amp;lt;b&amp;gt;Provincia: &amp;lt;/b&amp;gt;{nom_prov} ({cod_prov})&amp;lt;br/&amp;gt; &amp;lt;b&amp;gt;Cantón:&amp;lt;/b&amp;gt; {nom_cant} ({cod_canton})&amp;lt;br/&amp;gt; &amp;lt;b&amp;gt;Distrito:&amp;lt;/b&amp;gt; {nom_distr} ({cod_distr})",
        title: "Ubicación del punto",
        location: { latitude: latwgs, longitude: lonwgs },

      }
    });
popup.open({
                title: "Esta es la ubicación de su punto",
                location: centerPoint,
                feature: [districts],
                content: "{nom_prov}"
            });​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I got the following error:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(index):119 [esri.core.Accessor] Accessor#set Assigning an instance of 'esri.layers.FeatureLayer' which is not a subclass of 'esri.Graphic'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thought ?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 17:35:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1073340#M73659</guid>
      <dc:creator>DiegoMonge_Chinchilla</dc:creator>
      <dc:date>2021-06-28T17:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically open a popup template on a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1073402#M73662</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/374176"&gt;@DiegoMonge_Chinchilla&lt;/a&gt;&amp;nbsp; Just like the error is telling you, You are passing a FeatureLayer to the popups feature property when it is expecting a Graphic or array of Graphics. So something like&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const query = new Query();
query.where = "1=1";
query.outSpatialReference = { wkid: 102100 };
query.returnGeometry = true;
query.outFields = [ "nom_prov" ];

districts.queryFeatures(query).then(function(results){
  popup.open({
    title: "Esta es la ubicación de su punto",
    location: centerPoint,
    feature: results.features[0],
    content: "{nom_prov}"
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Would work.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 19:24:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1073402#M73662</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-06-28T19:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically open a popup template on a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1073715#M73676</link>
      <description>&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;I forgot to mention that I'm not a developer, I'm forest engineer so I don't know much about coding.&lt;BR /&gt;&lt;BR /&gt;After a few tries it works with the following adjustments in case someone else needs it:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const query = districts.createQuery();
            query.geometry = view.center;
            query.spatialRelationship = "intersects";
            // query.distance = 2;
            // query.units = "meters";
            query.where = "1=1";
            query.outSpatialReference = { wkid: 102100 };
            query.returnQueryGeometry = true;
            query.outFields = ["nom_prov"];

            districts.queryFeatures(query).then(function (results) {
                console.log(results)
                popup.open({
                    title: "Esta es la ubicación de su punto",
                    location: centerPoint,
                    // feature: results.features[0],
                    content: results.features[0].attributes.nom_prov
                });
            });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your kind help&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1104"&gt;@RobertScheitlin__GISP&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 15:03:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-open-a-popup-template-on-a/m-p/1073715#M73676</guid>
      <dc:creator>DiegoMonge_Chinchilla</dc:creator>
      <dc:date>2021-06-29T15:03:05Z</dc:date>
    </item>
  </channel>
</rss>

