Select to view content in your preferred language

ArcGIS JS API Feature Layer Label not displaying for dynamicDataSource join table rightTableSource "query-table"

98
1
2 weeks ago
SaurabhUpadhyaya
Occasional Contributor

Hello Friends,

I have one feature layer which we are joining using dynamic data source using "query-table" and wanted to concatenante label feature.id with feature.name (which is from right data source). Can you please suggest workaround, how to deal with this?

 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  <title>MapImageLayer - dynamic data layer with table join | Sample | ArcGIS Maps SDK for JavaScript 4.19</title>
  <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
  <script src="https://js.arcgis.com/4.19/"></script>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>
  <script>
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/FeatureLayer",
      "esri/widgets/Legend",
      "esri/widgets/Search",
      "esri/PopupTemplate"
    ], (Map, MapView, FeatureLayer, Legend, Search, PopupTemplate) => {

      

      var queryString =
        "Select objectid, join_id, name from sde.sampletable";

      const layer = new FeatureLayer({
        url: "https://sample/MapServer",
        title: "SIQ",

        labelingInfo: [
          {
            labelExpressionInfo: {
              expression: "$feature['id'] + ' ' + $feature['name']"
            },
            labelPlacement: "always-horizontal",
            symbol: {
              type: "text",
              color: [255, 255, 255, 0.7],
              haloColor: [0, 0, 0, 0.7],
              haloSize: 1,
              font: {
                size: 11
              }
            }
          }
        ],
        dynamicDataSource: {
          type: "data-layer",
          dataSource: {
            type: "join-table",
            leftTableSource: {
              type: "map-layer",
              mapLayerId: 1
            },
            rightTableSource: {
              type: "data-layer",
              dataSource: {
                type: "query-table",
                workspaceId: "101",
                query: queryString,
                oidFields: "objectid"
              }
            },
            leftTableKey: "id",
            rightTableKey: "join_id",
            joinType: "left-inner-join"
          }
        }
      });

      const map = new Map({
        basemap: "topo-vector",
        layers: [layer]
      });

      const view = new MapView({
        container: "viewDiv",
        map: map,
        zoom: 4,
        center: [-101.088, 40.969]
      });

      

      
    });
  </script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>

 

0 Kudos
1 Reply
SaurabhUpadhyaya
Occasional Contributor

Hello friends,

is any update?

0 Kudos