<?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: Concatenate two fields in pop up in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258483#M80267</link>
    <description>&lt;P&gt;Are you getting any errors in the console by chance?&amp;nbsp; Just looking at the code snippet provided I'm not seeing anything that jumps out as me as being wrong either.&amp;nbsp; You might try simplifying things and seeing if you can get one simple expression to work and then build up from there.&amp;nbsp; One thing I'm not totally sure of is if `fieldInfos` will take the expression with the `Textformatting.NewLine` function in it.&amp;nbsp; You might try removing it as a test.&lt;BR /&gt;&lt;BR /&gt;Is there any way you could send a codepen or some other complete sample that works except for the popup expressions to help debug?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 14:36:18 GMT</pubDate>
    <dc:creator>Sage_Wall</dc:creator>
    <dc:date>2023-02-15T14:36:18Z</dc:date>
    <item>
      <title>Concatenate two fields in pop up</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1257896#M80243</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I would like concatenate two attributes&amp;nbsp; in pop up. I 'd like to merge these attributes&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KARIMLABIDI_0-1676370092812.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62789i13F60CBEB26F6155/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KARIMLABIDI_0-1676370092812.png" alt="KARIMLABIDI_0-1676370092812.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;like that&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KARIMLABIDI_1-1676370127133.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62790i41001BB28DADA85B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KARIMLABIDI_1-1676370127133.png" alt="KARIMLABIDI_1-1676370127133.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 10:22:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1257896#M80243</guid>
      <dc:creator>KARIMLABIDI</dc:creator>
      <dc:date>2023-02-14T10:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate two fields in pop up</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258003#M80246</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/136432"&gt;@KARIMLABIDI&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The easiest way to do this would be to use an Arcade expression to concatenate the two attribute values:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/text_functions/#concatenate" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/text_functions/#concatenate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Concatenate([$feature.FIELD1&lt;/SPAN&gt;&lt;SPAN&gt;, TextFormatting.NewLine, $feature.FIELD2&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then use that arcade expression in your popup.&amp;nbsp; There is an sample for using arcade in popups located here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/popuptemplate-arcade/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/popuptemplate-arcade/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 15:09:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258003#M80246</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2023-02-14T15:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate two fields in pop up</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258430#M80260</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/507049"&gt;@Sage_Wall&lt;/a&gt;&amp;nbsp;but it doesn't work. I tried with Concatenate and without this function and nothing happens.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;//ARCADE 
        const arcadeExpressionInfos = [
  {
    name: "loca",
    title: "Localisation",
    // defined in separate script element
    expression:  `$feature.IDARRET+ TextFormatting.NewLine + $feature.IDARRET" `
  }, {
      name: "Coord",
      title: img_coord, 
      expression:
      `function MetersToLatLon(x, y) {
    // Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
     // Fuente: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
    var originShift = 2.0 * PI * 6378137.0 / 2.0;

    var lon = (x / originShift) * 180.0;
    var lat = (y / originShift) * 180.0;

    lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
    return [lat, lon];
}

var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
//var url = CreateWazeURL(latlon[0], latlon[1]);
//return round(latlon[0],2)+"-------"+ round(latlon[1],2);
    var a = 6378137; //demi grand axe de l'ellipsoide (m)
    var e = 0.08181919106; //première excentricité de l'ellipsoide
    var l0 = PI /180 * 3
    var lc = l0
    var phi0 = PI / 180 * 46.5   // latitude d origine en radian
    var phi1 = PI / 180 * 44   // 1er parallele automécoïque
    var phi2 = PI / 180 * 49    // 2eme parallele automécoïque
    
    var x0 = 700000; //coordonnées à l'origine
    var y0 = 6600000; //coordonnées à l'origine
    var long = latlon[0]
    var lat = latlon[1]
    var phi = (PI / 180) * long;
    var l = (PI / 180) * lat;
       
     //calcul des grandes normales
    var gN1 = a / Sqrt(1 - e * e * Sin(phi1) * Sin(phi1));
    var gN2 = a / Sqrt(1 - e * e * Sin(phi2) * Sin(phi2));
    
    //calculs des latitudes isométriques
        var gl1 = Log(Tan(PI / 4 + phi1 / 2) * Pow((1 - e * Sin(phi1)) / (1 + e * Sin(phi1)), e / 2));
        var gl2 = Log(Tan(PI / 4 + phi2 / 2) * Pow((1 - e * Sin(phi2)) / (1 + e * Sin(phi2)), e / 2));
        var gl0 = Log(Tan(PI / 4 + phi0 / 2) * Pow((1 - e * Sin(phi0)) / (1 + e * Sin(phi0)), e / 2));
        var gl = Log(Tan(PI / 4 + phi / 2) * Pow((1 - e * Sin(phi)) / (1 + e * Sin(phi)), e / 2));
 
 //calcul de l'exposant de la projection
        var n = (Log((gN2 * Cos(phi2)) / (gN1 * Cos(phi1)))) / (gl1 - gl2);//ok
    
    //calcul de la constante de projection
        var c = ((gN1 * Cos(phi1)) / n) * Exp(n * gl1);//ok
        //calcul des coordonnées
        var ys = y0 + c * Exp(-1 * n * gl0);
 
        var $x = x0 + c * Exp(-1 * n * gl) * Sin(n * (l - lc));
       // var y93 = ys - c * Exp(-1 * n * gl) * Cos(n * (l - lc));
    //var $x= (($c*exp(-$n*($lat_iso)))*sin($n*(latlon[0]-3)/180*PI)+$xs);
    var $y = ys - c * Exp(-1 * n * gl) * Cos(n * (l - lc));
    
    return round($x,2) +TextFormatting.NewLine+ round($y,2)`

 }
];

  //TEMPLATE
  const template = {
          // autocasts as new PopupTemplate()
          title: "{IDARRET} / {NOMARRET} &amp;lt;i&amp;gt;/ {MNLP_HASTUS}&amp;lt;/i&amp;gt;",
          lastEditInfoEnabled : false,
          content:
          [
            {
              // It is also possible to set the fieldInfos outside of the content
              // directly in the popupTemplate. If no fieldInfos is specifically set
              // in the content, it defaults to whatever may be set within the popupTemplate.
              type: "fields",
              fieldInfos: [
                {
                  fieldName: "expression/loca",
                  //expression : arcadeExpressionInfos,
                  label: img_adresse,
                },
                {
                  fieldName: "VILLE",
                  label: "Ville",
                },
                {
                  fieldName: "MNLP_HASTUS",
                  label: "MNLP Hastus",
                },   
                {
                fieldName: "expression/Coord",
                
              }          
              ],
              expressionInfos: arcadeExpressionInfos
            }
          ],
          
          actions: [editPROD,editPROJ1,editPROJ2],
         
          
        };&lt;/LI-CODE&gt;&lt;P&gt;And on the pop up,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KARIMLABIDI_0-1676464397847.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62916iEC87EEAFE6E95DFC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KARIMLABIDI_0-1676464397847.png" alt="KARIMLABIDI_0-1676464397847.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This link helps me&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=popuptemplate-arcade" target="_self"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=popuptemplate-arcade&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I don't know what I missed!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 12:35:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258430#M80260</guid>
      <dc:creator>KARIMLABIDI</dc:creator>
      <dc:date>2023-02-15T12:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate two fields in pop up</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258483#M80267</link>
      <description>&lt;P&gt;Are you getting any errors in the console by chance?&amp;nbsp; Just looking at the code snippet provided I'm not seeing anything that jumps out as me as being wrong either.&amp;nbsp; You might try simplifying things and seeing if you can get one simple expression to work and then build up from there.&amp;nbsp; One thing I'm not totally sure of is if `fieldInfos` will take the expression with the `Textformatting.NewLine` function in it.&amp;nbsp; You might try removing it as a test.&lt;BR /&gt;&lt;BR /&gt;Is there any way you could send a codepen or some other complete sample that works except for the popup expressions to help debug?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 14:36:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258483#M80267</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2023-02-15T14:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate two fields in pop up</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258501#M80271</link>
      <description>&lt;P&gt;I found!!The arcade expressions have to be in the template properties and not out. With your function concatenate it works.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;//TEMPLATE
  const template = {
          // autocasts as new PopupTemplate()
          title: "{IDARRET} / {NOMARRET} &amp;lt;i&amp;gt;/ {MNLP_HASTUS}&amp;lt;/i&amp;gt;",
          lastEditInfoEnabled : false,
          expressionInfos:  [{
    name: "loca",
    title: "Localisation",
    // defined in separate script element
    expression:  `Concatenate([$feature.ADRESSE, TextFormatting.NewLine, $feature.VILLE])`
    
  },
    {
      name: "Coord",
      title: img_coord, 
      expression: 
      `function MetersToLatLon(x, y) {
    // Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
     // Fuente: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
    var originShift = 2.0 * PI * 6378137.0 / 2.0;

    var lon = (x / originShift) * 180.0;
    var lat = (y / originShift) * 180.0;

    lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
    return [lat, lon];
}

var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
//var url = CreateWazeURL(latlon[0], latlon[1]);
//return round(latlon[0],2)+"-------"+ round(latlon[1],2);
    var a = 6378137; //demi grand axe de l'ellipsoide (m)
    var e = 0.08181919106; //première excentricité de l'ellipsoide
    var l0 = PI /180 * 3
    var lc = l0
    var phi0 = PI / 180 * 46.5   // latitude d origine en radian
    var phi1 = PI / 180 * 44   // 1er parallele automécoïque
    var phi2 = PI / 180 * 49    // 2eme parallele automécoïque
    
    var x0 = 700000; //coordonnées à l'origine
    var y0 = 6600000; //coordonnées à l'origine
    var long = latlon[0]
    var lat = latlon[1]
    var phi = (PI / 180) * long;
    var l = (PI / 180) * lat;
       
     //calcul des grandes normales
    var gN1 = a / Sqrt(1 - e * e * Sin(phi1) * Sin(phi1));
    var gN2 = a / Sqrt(1 - e * e * Sin(phi2) * Sin(phi2));
    
    //calculs des latitudes isométriques
        var gl1 = Log(Tan(PI / 4 + phi1 / 2) * Pow((1 - e * Sin(phi1)) / (1 + e * Sin(phi1)), e / 2));
        var gl2 = Log(Tan(PI / 4 + phi2 / 2) * Pow((1 - e * Sin(phi2)) / (1 + e * Sin(phi2)), e / 2));
        var gl0 = Log(Tan(PI / 4 + phi0 / 2) * Pow((1 - e * Sin(phi0)) / (1 + e * Sin(phi0)), e / 2));
        var gl = Log(Tan(PI / 4 + phi / 2) * Pow((1 - e * Sin(phi)) / (1 + e * Sin(phi)), e / 2));
 
 //calcul de l'exposant de la projection
        var n = (Log((gN2 * Cos(phi2)) / (gN1 * Cos(phi1)))) / (gl1 - gl2);//ok
    
    //calcul de la constante de projection
        var c = ((gN1 * Cos(phi1)) / n) * Exp(n * gl1);//ok
        //calcul des coordonnées
        var ys = y0 + c * Exp(-1 * n * gl0);
 
        var $x = x0 + c * Exp(-1 * n * gl) * Sin(n * (l - lc));
       // var y93 = ys - c * Exp(-1 * n * gl) * Cos(n * (l - lc));
    //var $x= (($c*exp(-$n*($lat_iso)))*sin($n*(latlon[0]-3)/180*PI)+$xs);
    var $y = ys - c * Exp(-1 * n * gl) * Cos(n * (l - lc));
    
    return round($x,2) +TextFormatting.NewLine+ round($y,2)`

 } ],
          content:
          [
            {
              // It is also possible to set the fieldInfos outside of the content
              // directly in the popupTemplate. If no fieldInfos is specifically set
              // in the content, it defaults to whatever may be set within the popupTemplate.
              type: "fields",
              fieldInfos: [
                {
                  fieldName: "expression/loca",
                  //expression : "$feature.ADRESSE",
                  label: img_adresse,
                },
                {
                fieldName: "expression/Coord",
                
              }          
              ],
            }
          ],
          
          actions: [editPROD,editPROJ1,editPROJ2],
         
          
        };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KARIMLABIDI_0-1676473601993.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62927i9C018F87E2E6803A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KARIMLABIDI_0-1676473601993.png" alt="KARIMLABIDI_0-1676473601993.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/507049"&gt;@Sage_Wall&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 15:06:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/concatenate-two-fields-in-pop-up/m-p/1258501#M80271</guid>
      <dc:creator>KARIMLABIDI</dc:creator>
      <dc:date>2023-02-15T15:06:56Z</dc:date>
    </item>
  </channel>
</rss>

