Select to view content in your preferred language

Customize LayerList widget to add interactive image between layers

1762
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
16 Replies
Sunita_Khanal
New Contributor II

Yes, so I copied that file and it showed up, thank you so much for this. Greatly appreciated. 

Can I ask a follow-up question on this? what code do I have to change to move the image below the tree icon. 

Thanks,

Sunita

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I don't understand the question.

0 Kudos
Sunita_Khanal
New Contributor II

So, I want the symbol for the Not-a-tree or other Lifecycle above the image, if that makes sense.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

In the code you provided I only see you adding one image... So where is the other one coming from? Is it the symbol for that layer?

0 Kudos
Sunita_Khanal
New Contributor II

That's a symbology from the layer and it appears below the added image when the layer is expanded and I want that symbology to go above the Tree Campus USA image.

Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sunita,

   Then your domConstruct.place(layerTrNode, node, 'after'); is the issue. instead of node you need to find the layers symbol node and place it after that.

Sunita_Khanal
New Contributor II

Thank you so much, Robert. I very much appreciate your time and input. 

Sunita

0 Kudos