I am developing an application based on WAB. Since I have some services with complicated legend I made the legend widget to reference to a pre made images for legend.
I have my own print template with Title, Author, copyright and legend elements. I am working to include these images in the place of the legend element or any other element so that the map got an appropriate legend element in the printout.
If you see the PrintTemplate() object we have access to these layout elements in the LayoutOptions object as properties.
// this script is a piece from the print.js
template.layoutOptions = {
authorText: hasAuthorText ? form.author : "",
copyrightText: hasCopyrightText ? (form.copyright || this._getMapAttribution()) : "",
legendLayers: this._getLegendLayers(), // fix issue 7744
titleText: hasTitleText ? form.title : "",
customTextElements: cteArray
};
the layout elements (authorText, copyrightText, titleText....) are taking their values from the form or we can hardcode the value here. Is there a way then to place my image in any of these elements based on which layer is visible in the map for printing? the hardest thing i experienced is to access the node (the physical places) where these elements are appended in to the print template . Any Idea is appreciated.
Mehretab
Mehretab,
The way you are approaching this is wrong. What you need to do is setup custom print templates and choose the template based on your criteria. The custom templates will have the legend element removed and have your static legend image added to the layout.
Tutorial: Publishing additional services for printing—Documentation | ArcGIS Enterprise
https://community.esri.com/thread/185595-can-you-format-print-layoutstemplates-in-wab-or-portal
Robert,
Thanks as always. sorry for not been clear, in my test environment I am already working with custom print templates. This custom print template has:
As you recommended I can create new custom print templates without legend element, but the real problem remains where do I have to put the images (supposed to serve as legends) in the template? The images in the map printout must also change according to which service is displayed in the map as they do in legend widget in the above application.
where do I have to put the images (supposed to serve as legends) in the template? Yes
The images in the map printout must also change according to which service is displayed in the map as they do in legend widget in the above application: So you have a separate layout for each.
'So you have a separate layout for each'. Do you mean I will have a layout with a static image (the legend image) for every service? if so I will have as many layout as the number of my service which are fairly many.
No not at all. Are you saying that the standard layout with a dynamic legend will NEVER work for you?.. I thought that you were just talking about a couple of specific circumstances.
standard layout with a dynamic legend works well but instead of the dynamic legend I want to use images if possible in the legend elements places or even on other elements. I Preferred this approach because the dynamic legend is going to be really a mess with the amount of sub layers in every service within the application.
I don't have a good suggestion for you then if you are wanting to do this for everything. There is not a way that I am aware of to pass an image to the layout.