Popup title

697
1
07-11-2021 09:01 AM
jkumartry1980
New Contributor II

Dear All,

In my application popup title displays first field value, instead I need to display layer title (refer attached snapshot).

Screenshot 2021-07-11 212328.jpg

 

 

 I have use popup.open as shown below. "dict" refers collection of features selected in the map.

 

view.popup.open({ features: dict, featureMenuOpen: false, updateLocationEnabled: true ,highlightEnabled :true , collapseEnabled :false,includeDefaultActions : true });

 

 

Please help me to resolve this issue. Please note I didn't use popuptemplate

0 Kudos
1 Reply
DougSims_GT
Occasional Contributor

You can create a PopupTemplate for each layer and set the title to the layer name that way. Then create a Popup and set the title and content properties to the attributes of this template object.

var layer1Template = new PopupTemplate({
          title: "Layer1 Title Here",
          content: "All of your fields and labels go here."
        });
 
var layer1Popupnew Popup({
          autoClosedEnabled: true,
          title: layer1Template.title,
          content: layer1Template.content
        });
 
Alternatively, you can set the popupTemplate attribute in the feature layer when you create it:
const layer2Features = new FeatureLayer({
          url: "url goes here",
          popupEnabled: true,
          popupTemplate: layer2Template,
          legendEnabled: false,
          renderer: layer2Render
        });
 
I've used both of these strategies (in the same map in some cases) to customize each layer's popup. The sample code above comes from a map I authored in 4.11, but it should still work in the current version.
0 Kudos