WAB Printing Legend issues: Query Result Layer

5776
25
01-18-2016 11:26 AM
MonikaHonkova2
New Contributor II

Hello,

I created a query using the Query widget and added the result as an operational layer to my map. The legend looks ok in the Legend widget but I don't understand why it's showing a label "Override 1" next to the legend patch in the printed map.

Also as you can see on the attached image, the symbol for the original map layer (polygon, no fill, pink outlines) is missing from the legend.Capture.PNG

Is there a possible solution? Monika

25 Replies
davetinkle
New Contributor III

using JS API, and have upgraded every time in the hope someone would have fixed this. So that would make it 4.8 version. It's a known bug. I have a ticket. I don't know anything about GDI. All I know is I followed the API & printing a legend for a PDF is advertised as part of its core functionality, but it simply does not work.

Thanks.

TanuHoque
Esri Regular Contributor

Dave, sorry to hear that. Could you pls pass me your ticket #? and if possible, pls share the webmap_as_json string that gets sent to your print service from your app?

thanks.

0 Kudos
davetinkle
New Contributor III

Unfortunately, our code has branched too many times to retrieve what was causing it to fail. It would be very disruptive to revert, compile, deploy, trap packets & put it here.

Don’t have a ticket number, but do have Case #02114883 & bug #BUG-000114062

Do you ask b/c you are part of the development team?

0 Kudos
TanuHoque
Esri Regular Contributor

Thanks Dave for sharing the bug#. I took a look and I noticed you are using featureCollection instead of featureLayer, right?

Seems like there is an issue with featureCollection especially when it gets serialized into the json that gets sent to a print service. I have informed the appropriate team and they said they would take a look.

In the meantime, would it be possible to give it a try with a featurelayer (instead of a featureCollection)?

pls see the json below that uses featureLayer.

{ "operationalLayers": [{ "id": "dark-gray-base-layer", "title": "World Dark Gray Base", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer", "token": null }, { "id": "Cities", "title": "Cities", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "https://services.arcgis.com/Wl7Y1m92PbjtJs5n/ArcGIS/rest/services/Californiaaa/FeatureServer/4", "token": null, "layerDefinition": {"drawingInfo": { "renderer": { "symbol": { "type": "esriSMS", "color": [0, 0, 0, 255], "xoffset": 0, "yoffset": 0, "size": 6, "style": "esriSMSCircle", "outline": { "type": "esriSLS", "color": [255, 255, 255, 255], "width": 0.5, "style": "esriSLSSolid" } }, "type": "simple" } } } }, { "id": "dark-gray-reference-layer", "title": "World Dark Gray Reference", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer", "token": null }], "mapOptions": { "extent": { "spatialReference": { "latestWkid": 3857, "wkid": 102100 }, "xmin": -18971512.898950197, "ymin": 1292277.143967695, "xmax": -186348.82759027556, "ymax": 8004059.723630667 }, "spatialReference": { "latestWkid": 3857, "wkid": 102100 }, "scale": 73957190.948944 }, "exportOptions": { "dpi": 96 }, "layoutOptions": { "titleText": "Esri test reproduction", "authorText": "Esri", "copyrightText": "Esri inc", "customTextElements": [], "scaleBarOptions": {  }, "legendOptions": { "operationalLayers": [{ "id": "Cities" }] } } }

... if you use this json as a value to WebMap_as_JSON parameter with the print service available on sampleserver6, and execute, you will get the following output.

    

please let me know if you have any question. Thanks.

0 Kudos
davetinkle
New Contributor III

Tanu,

I delayed my response because I was assured this would be fixed in the next API release [how an unrelated Print service is related to an API release is still unclear to me].

I never used a FeatureCollection.

I have always used FeatureLayer.

To date, it still is NOT fixed, and does NOT appear to be correlated to the javascript API version, currently 4.11. I am using 4.6.

Please explain both

[1] why it isn't fixed, and feel free to correct me if it is

[2] if there is a work around so when I print [using the print task, NOT the print widget], my legend also prints. The end resultant PNG/PDF **must, must, must** have the legend on the final product.

Thanks.

Noah-Sager
Esri Regular Contributor

Hi Dave,

Sorry to hear about this ongoing issue. I'd like to investigate your use case and see where the trouble is. 

Printing a FeatureLayer from a URL or portalItem should be fine. Printing a FeatureLayer from a Collection can be an issue. However, based on the screenshot supplied above, I believe what is being added to the map is a GraphicsLayer. Can you confirm? 

I am currently looking into the Bug # and Case # that you referenced above to try to understand better.

-Noah

0 Kudos
davetinkle
New Contributor III

[replied to email that assured me it would be posted here, but it did not, so i'm posting directly now w/ my emailed response from yesterday]

---------------------------------------------------

Hi Noah,

 

Using a FeatureLayer. Here’s the simple fn I wrote that first revealed the issue [not drop-in ready, but close enough]:

 

 

function printSubmit():

 

    require(["esri/tasks/PrintTask", "esri/tasks/support/PrintTemplate","esri/tasks/support/PrintParameters", "esri/tasks/support/LegendLayer"],

    function(PrintTask, PrintTemplate, PrintParameters, LegendLayer) {

             

    disableButton('downloadButton','disableSubmitButton','canAddMapToCad','canAddToCad');

    showDownloadProgressBar();

      

    var pt = new PrintTask({

        url: printTaskUrl

    });

    var template = new PrintTemplate();

                    

    var d = new Date();

    var mm = d.getMonth() + 1; if (mm < 10) mm = '0' + mm;

    var dd = d.getDate(); if (dd < 10) dd = '0' + dd;

    var yyyy = d.getFullYear();

 

 

    var legendLayers = [];

    // for now, do not show legend, as there's a known bug where 'Override 1' is displayed, instead of layer id/store type description

    // ref: https://community.esri.com/thread/170974 & https://community.esri.com/thread/101287

    map.allLayers.forEach(function(item, i) {

       if (item.declaredClass == "esri.layers.FeatureLayer") {

             var l = new LegendLayer({

                layerId: item.id,

                title: " "

             });

             legendLayers.push(l);

        }

    })

    template.layoutOptions = {

           titleText: mapTitle,

           authorText: "ALERT Report Generated: " + mm + "/" + dd + "/" + yyyy,

           copyrightText: "SBU - Sensitive But Unclassified",

           legendLayers: legendLayers

    };

    template.format = "png32";

    template.exportOptions = {

        width: $("#mapDiv").width(),

        height: $("#mapDiv").height()

    };

                    

    var pp = new PrintParameters();

    pp.view = view;

    pp.template = template;

    pt.execute(pp).then(printComplete, printError);

      

})}

 

Hope this helps in your investigation. We’re still obliged to provide this service, so the ticket’s still valid. There is no workaround to the best of my knowledge.

 

Thanks.

TanuHoque
Esri Regular Contributor

Hi Dave,

apologies for the late reply. was extremely busy.

it appears to me that this bug might not have fixed yet. I have contacted JS API team and hope to get back to you soon.

0 Kudos
TUANNGUYEN1
New Contributor II

Has anyone had a final solution for this issue?

LarsDe_Sloover
New Contributor

@Noah-Sager @TanuHoque 

In the meantime, the fifth (!) anniversary of this issue has passed. Why is this problem still not resolved?

0 Kudos