Select to view content in your preferred language

Changing PopupTemplate for Feature

215
0
10-10-2024 11:57 PM
JonathanAttard
Occasional Contributor

Hello, I'm having trouble updating the popupTemplate for a Feature in the Query Widget. I've successfully modified popupTemplates before, including for the Map Widget and an earlier version of the Query Widget.

The issue isn't that I can't change the popup at all, it's specifically with the 'expression' content types not working. Other content types, like 'text', work just fine. Strangely, the same 'expression' content works perfectly in the Map Widget but fails in the Query Widget.

Does anyone know what might be causing this?

Kindly refer to the code below:

Feature element: query/src/runtime/components/feature-info.tsx

 

      this.feature = new this.Feature({
        container: container,
        defaultPopupTemplateEnabled: true,
        // @ts-expect-error
        spatialReference: this.props.dataSource?.layer?.spatialReference || null,
        // @ts-expect-error
        map: rootDataSource?.map || null,
        graphic: this.props.graphic,
        visibleElements: this.getVisibleElements()
      })

 

 

 

Popup Template Modification 

 

  popupTemplate.content = [
    // This does not work, however works with Map Widget
    {
      type: 'expression',
      expressionInfo: {
        expression: `
          var content = "<div>First test</div>";

          return { 
            type: 'text', 
            text: content
          };
        `
      }
    },
    // This works
    {
      type: "text",
      text: "<div>Second test</div>"
    }
  ]

 

 

0 Kudos
0 Replies