Feature widget in a side panel

This sample is similar to the Feature widget sample with the exception that this sample demonstrates docking the widget into a side panel. This is useful in circumstances where you may not necessarily want or need the associated feature's information to display directly within the map. It displays information based on the PopupTemplate using the Feature widget. The content of the PopupTemplate is saved within the referenced layer and makes use of custom text elements with chart media.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
          // Provide graphic to a new instance of a Feature widget
          const feature = new Feature({
            container: "feature-node",
            graphic: graphic,
            map: view.map,
            spatialReference: view.spatialReference
          });

          view.whenLayerView(fLayer).then((layerView) => {
            let highlight;
            let objectId;

            const debouncedUpdate = promiseUtils.debounce(async (event) => {
              // Perform a hitTest on the View
              const hitTest = await view.hitTest(event, { include: fLayer });
              // Make sure graphic has a popupTemplate
              const results = hitTest.results.filter((result) => {
                return result.graphic.layer.popupTemplate;
              });

              const result = results[0];
              const newObjectId = result && result.graphic.attributes[fLayer.objectIdField];

              if (!newObjectId) {
                highlight?.remove();
                objectId = feature.graphic = null;
              } else if (objectId !== newObjectId) {
                highlight?.remove();
                objectId = newObjectId;
                feature.graphic = result.graphic;
                highlight = layerView.highlight(result.graphic);
              }
            });
            // Listen for the pointer-move event on the View
            view.on("pointer-move", (event) => {
              debouncedUpdate(event).catch((err) => {
                if (!promiseUtils.isAbortError(err)) {
                  throw err;
                }
              });
            });

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.