HOW TO
In ArcGIS Dashboards, images can be incorporated into list elements based on defined conditions to provide visual context and help users interpret the displayed information more easily. In scenarios where images are hosted externally, their URLs can be incorporated through advanced formatting and referenced within the element's HTML formatting. For example, in an asset monitoring dashboard, transformer icons hosted externally can be displayed for active assets and alternate symbols for inactive ones, based on defined conditions. This article provides the workflow to configure conditional expressions in advanced formatting to display externally hosted images in ArcGIS Dashboards list elements.
var <variable_name> = When(
$datapoint.<field> == '<attribute>', '<p><img src="<image_URL>"/></p>',
'<p><img src="<default_URL>"/></p>'
);
Note: Repeat the second line as desired to define all necessary conditions. Include a comma between conditions.
In this example, the conditional expression consists of four conditions set to display different images hosted on a public website. The following example shows the complete expression used in this workflow.
var img = When(
$datapoint.TYPE == 'Clinic', '<p><img src="https://i.postimg.cc/kGD0KzjG/clinic-icon.png"/></p>',
$datapoint.TYPE == 'Hospital', '<p><img src="https://i.postimg.cc/1Xgdf6t4/hospital-icon.png"/></p>',
$datapoint.TYPE == 'Long Term Care', '<p><img src="https://i.postimg.cc/NjvnjKw4/long-term-care-icon.png"/></p>',
$datapoint.TYPE == 'Agency / Hospice', '<p><img src="https://i.postimg.cc/3RqS5RBH/hospice-icon.png"/></p>',
'<p><img src="https://i.postimg.cc/HxXvQHm3/Medical-center-image.jpg"/></p>'
);
return {
attributes: {
<variable_name>
}
};
The following is an example of a complete expression in the editor.
var img = When(
$datapoint.TYPE == 'Clinic', '<p><img src="https://i.postimg.cc/kGD0KzjG/clinic-icon.png"/></p>',
$datapoint.TYPE == 'Hospital', '<p><img src="https://i.postimg.cc/1Xgdf6t4/hospital-icon.png"/></p>',
$datapoint.TYPE == 'Long Term Care', '<p><img src="https://i.postimg.cc/NjvnjKw4/long-term-care-icon.png"/></p>',
$datapoint.TYPE == 'Agency / Hospice', '<p><img src="https://i.postimg.cc/3RqS5RBH/hospice-icon.png"/></p>',
'<p><img src="https://i.postimg.cc/HxXvQHm3/Medical-center-image.jpg"/></p>'
);
return {
attributes: {
img
}
};

drop-down arrow.
The new attribute is added to the editor, and the images are displayed in the preview area.

> Save to save the changes.Article ID: 000038429
Get help from ArcGIS experts
Start chatting now