Select to view content in your preferred language

Print Widget - default include attribute to false - please

162
2
Jump to solution
3 weeks ago
DanielScholes
Occasional Contributor

Hi There,

I have been working with the Print Widget, which is very helpful. I successfully wrote JavaScript to hide the Layout Tab. I couldn't find a standard setting for hiding it.  On the Map Only tab, the widget continues to default to true for "Include attribution". For my user case, we don't want it to default to true. Is there a way to set the default to false? I have written JavaScript to set it back to false when certain actions occur, but it doesn't always hold up well as a user makes a lot of interactions such as moving between tabs, opening and closing the advanced options, etc. It can become reset to true. Any default settings that hold would be very helpful.

Thank you in advance for responses,

Dan

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DanielScholes
Occasional Contributor

While this isn't optimal, I have found by setting the checkbox of the widget to false with an actual JavaScript ".click();" command solved my problem. I would much rather have an option when declaring the widget, so I'm still interested in hearing if that functionality exists.

Below is the code that worked for me. I call this in a few situations, such as when making the widget visible, clicking the "Map only" tab, and clicking the "Exports" tab. It is not the preferred method, but this works for the moment. 

const elements = document.querySelectorAll('[data-option-name="attributionEnabled"]');

for (let i = 0; i < elements.length; i++) {
    const itemLocal = elements[i];
    if (itemLocal.checked) {
        itemLocal.click();
    }
}                               

 

View solution in original post

0 Kudos
2 Replies
DanielScholes
Occasional Contributor

While this isn't optimal, I have found by setting the checkbox of the widget to false with an actual JavaScript ".click();" command solved my problem. I would much rather have an option when declaring the widget, so I'm still interested in hearing if that functionality exists.

Below is the code that worked for me. I call this in a few situations, such as when making the widget visible, clicking the "Map only" tab, and clicking the "Exports" tab. It is not the preferred method, but this works for the moment. 

const elements = document.querySelectorAll('[data-option-name="attributionEnabled"]');

for (let i = 0; i < elements.length; i++) {
    const itemLocal = elements[i];
    if (itemLocal.checked) {
        itemLocal.click();
    }
}                               

 

0 Kudos
Justin_Greco
Frequent Contributor

Disabling attribution is supported in the SDK, you need to set attributionEnabled to false in the templateOptions property of the print widget.

const print = new Print({

   view: view,

   templateOptions:{
      attributionEnabled: false
   }
);

 

0 Kudos