Select to view content in your preferred language

Customize LayerList widget to add interactive image between layers

1702
16
Jump to solution
09-12-2018 08:05 AM
Sunita_Khanal
New Contributor II

I want to add an image between the layers and embed it with a link so that when an image is clicked, the link will open in a new tab. I updated the Widget.js code within the show layers function (around line132) and I am partially successful i.e, my image won't display (as in the image below), but I am can click on the small icon to go to another page. I am a not sure what code I am missing for displaying the image. I am a newbie to WAB and programming and Any help will be highly appreciated. 

Thanks,

Sunita

setTimeout(lang.hitch(this, function(){
var node = query('.layer-tr-node-OsuStwTree_9178_1')[0];
var layerTrNodeClass = 'layer-tr-node-OsuStwTree_9178_1';
var layerTrNode = domConstruct.create('tr', {
'class': 'treeInventory',
'layerTrNodeId': 'OsuStwTree_9178_1'
});
var layerTdNode = domConstruct.create('td', {
'class': 'col col1',
'style': 'width: 40px;'
}, layerTrNode);
var layerTitleTdNode = domConstruct.create('td', {
'class': 'col col2'
}, layerTrNode);
var layerTitleDivIdClass = 'layer-title-div-OsuStwTree_9178_1';
var divLabel = domConstruct.create('div', {
'innerHTML': '<br><div id = "treeInventory"><br><a target="_blank" href="http://arbordayblog.org/tree-campus-usa/10-year-tree-campus-usa-spotlight-university-of-nebraska-lin..."><img height = "50px" src= "images/treeCampus.png"></a>',
'class':layerTitleDivIdClass + ' div-content jimu-float-leading',
style:{
height: this.height +'px'
}
}, layerTitleTdNode);
domConstruct.place(layerTrNode, node, 'after');
}), 1000);
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Sunita,

   What is the full path of the treeCampus.png image?

View solution in original post

0 Kudos
16 Replies
RobertScheitlin__GISP
MVP Emeritus

Sunita,

   What is the full path of the treeCampus.png image?

0 Kudos
Sunita_Khanal
New Contributor II

Here is the full path of my treeCampus.png

D:\WebAppBuilder\WebAppBuilderForArcGIS\server\apps\5\widgets\LayerList\images

Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

And when you hover over the broken image link icon what does it say the path it is using is?

0 Kudos
Sunita_Khanal
New Contributor II

It won't display any path. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Right click it and choose "inspect" (if using Chrome).

0 Kudos
Sunita_Khanal
New Contributor II

This is how it looks like in the chrome developer tool. 

Many thanks for taking the time to help solve this one. 

Sunita

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sunita,

   OK, now hover over the src property and see what path it displays in the tooltip.

0 Kudos
Sunita_Khanal
New Contributor II

It looks like this

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sunita,

   So you see having "images/treeCampus.png" goes to the Apps images folder and not the widgets images folder.