I'm working on converting a map app from Leaflet.js to the Esri JS API (4.x). I have a field that contains the URL to an image. However, not every record has an image.
I was planning on using the code below to add the image to the pop-up. However, I was wondering if there is a way to control the pop-up logic so that the image only appears if the value in the field is not false (technically null)?
Thanks for the help.
const popupTemplate = {
title: 'Survey Location: <strong>{expression/display-location}</strong>',
expressionInfos: [
{
name: 'display-location',
title: 'Location',
expression: "DefaultValue($feature.Loc_ID ,'Not Defined')"
},{
name: 'round-latitude',
title: 'Latitude',
expression: "Round($feature.LAT, 3)"
},
{
name: 'round-longitude',
title: 'Longitude',
expression: "Round($feature.LONG, 3)"
}, {
name: 'format-area',
title: 'Area Surveyed (sq. ft.)',
expression: "Text($feature.Area, '#,###')"
}
],
content: [
{
type: 'fields',
fieldInfos: [
{
fieldName: 'expression/round-latitude'
},
{
fieldName: 'expression/round-longitude'
},{
fieldName: 'expression/format-area'
}
]
},
{
type: 'media',
mediaInfos: [{
title: 'Survey Location: {expression/display-location}',
type: 'image',
value: {
sourceURL: '{IMG}'
}
}]
}
]
};