Attachments in Popup Template

900
1
02-14-2020 03:06 AM
MatthieuThery1
Occasional Contributor

Hi,

I am trying to show attachments in a popup (mapimagelayer) using that piece of code, and it's not working (I can see the attachment in the rest end point (pdf)):

popupTemplate: {
  outFields: ['*'],
  title:"test",
  content: [{type: "attachments"}]
}
0 Kudos
1 Reply
LeoLiu1
Occasional Contributor

Hi Matthieu,

Are you using 4.x API? Here is the example: 

AttachmentsContent | ArcGIS API for JavaScript 4.14 

// Create the AttachmentsContent popup element 
// If the selected feature has attributes associated with it, they will display within the popup 
let attachmentsElement = new AttachmentsContent({ displayType: "list" }); 
// Create the PopupTemplate 
let template = new PopupTemplate({ 
   title: "Beverly Hills trees by block", 
   outFields: ["*"], 
   content: [attachmentsElement] 
});‍‍‍‍‍‍‍‍‍

If you are using 3.x API, it should like this: 

Popup with related fields | ArcGIS API for JavaScript 3.31 

var popupTemplate = new PopupTemplate({
    "title": "Beverly Hills Trees By Block",
    "fieldInfos": [
     //...
     ],
    "description": "",
    "showAttachments": true,
    "mediaInfos": []
});‍‍‍‍‍‍‍‍‍

var featureLayer = new FeatureLayer([LAYERURL], {
    mode: FeatureLayer.MODE_SNAPSHOT,
    infoTemplate: popupTemplate,
    outFields: ["*"]
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos