Select to view content in your preferred language

PrintTemplate Dijit stops working when I add a dynamic layer

2323
5
Jump to solution
01-23-2014 07:54 AM
ionarawilson1
Deactivated User
I am using a printtemplate dijit that was posted on the samples page. Everything works fine, but if I add a certain layer, the print dijit does not work. Instead of showing Printout it just shows "Print" Does anybody know why this is happening? Thank you



Here is the layer that I add:

var petroFieldsMSL = new ArcGISDynamicMapServiceLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/MapServer/");
app.map.addLayer(petroFieldsMSL);



The dijit sample
https://developers.arcgis.com/en/javascript/jssamples/widget_print_esri_request.html


/ add graphics for pools with permits // I NEED SOMETHING HERE TO CREATE A PRINT MAP, I CAN CREATE A MAP SERVIC WITH A BLANK MAP         var permitUrl = "http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/MapServer/2";         var poolFeatureLayer = new FeatureLayer(permitUrl, {           "mode": FeatureLayer.MODE_SNAPSHOT,          visible:false         });         app.map.addLayer(poolFeatureLayer);           // get print templates from the export web map task         var printInfo = esriRequest({           "url": app.printUrl,           "content": { "f": "json" }         });         printInfo.then(handlePrintInfo, handleError);          function handlePrintInfo(resp) {           var layoutTemplate, templateNames, mapOnlyIndex, templates;            layoutTemplate = arrayUtils.filter(resp.parameters, function(param, idx) {             return param.name === "Layout_Template";           });                      if ( layoutTemplate.length == 0 ) {             console.log("print service parameters name for templates must be \"Layout_Template\"");             return;           }           templateNames = layoutTemplate[0].choiceList;            // remove the MAP_ONLY template then add it to the end of the list of templates            mapOnlyIndex = arrayUtils.indexOf(templateNames, "MAP_ONLY");           if ( mapOnlyIndex > -1 ) {             var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];             templateNames.push(mapOnly);           }                      // create a print template for each choice           templates = arrayUtils.map(templateNames, function(ch) {             var plate = new PrintTemplate();             plate.layout = plate.label = ch;             plate.format = "PDF";             plate.layoutOptions = {                "authorText": "Texas A&M Forest Service",                "legendLayers": [],                "titleText": "Activity Point",                "scalebarUnit": "Miles"              };             return plate;           });            // create the print dijit           app.printer = new Print({             "map": app.map,             "templates": templates,             url: app.printUrl           }, dom.byId("print_button"));           app.printer.startup();         }          function handleError(err) {           console.log("Something broke: ", err);         }      featuremapServiceSource = "http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/FeatureServer/";         var stewardship = new esri.layers.FeatureLayer(featuremapServiceSource + "/" + 0,      {                   mode: FeatureLayer.MODE_SELECTION, id: 'stewardship',           outFields: ['*']             }); app.map.addLayers(stewardship);    var highlightSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([255,255,0,.6]));            highlightSymbol.setSize(9)                stewardship.setSelectionSymbol(highlightSymbol);  // I NEED THIS TO RUN THE GP SERVICE, THIS IS TO HAVE GRAPHICS ON THE MAP  var petroFieldsMSL = new ArcGISDynamicMapServiceLayer("http://tfsgis-iisd01:6080/arcgis/rest/services/FeatureServiceStewAAreaAPoint/MapServer/");       petroFieldsMSL.setDisableClientCaching(true);   //When I add this the printing dijit stops working  app.map.addLayer(petroFieldsMSL); // So not to have another layer besides stewardship     petroFieldsMSL.setVisibleLayers([0])       dojo.connect(app.map, 'onLoad', function(map) {           initToolbar(app.map);         });


And the error I am getting in FF:



The resource from this URL is not text: http://js.arcgis.com/3.6/
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Deactivated User
What is app.printUrl?

If you're using the service referenced in our samples then it's not going to work??? use a print service from your own ArcGIS Server or make all the services you want to print available on the public web. The reason for this is that the print service has to be able to directly access the services that need to be printed.

View solution in original post

0 Kudos
5 Replies
ionarawilson1
Deactivated User
Anybody has any ideas? I desperately need this to work! Thank you for any ideas you can provide!
0 Kudos
derekswingley1
Deactivated User
What is app.printUrl?

If you're using the service referenced in our samples then it's not going to work??? use a print service from your own ArcGIS Server or make all the services you want to print available on the public web. The reason for this is that the print service has to be able to directly access the services that need to be printed.
0 Kudos
ionarawilson1
Deactivated User
Yes, the print url is from esri:

app.printUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%2...";

So right now, my dynamic layer service is in the development server. So you are saying if I publish it on the production server (public), then I can use your gp service, right?
Otherwise, is it really hard to create my own gp service for printing? Are there are tutorials or help for that or it is pretty straightforward?
Thank you so much for helping us here. I am a newbie in javascript so thanks this is great!!!
0 Kudos
derekswingley1
Deactivated User
The service on sampleserver6 is for samples and demos. It's there to show what is possible, not as a resource for public apps. While sampleserver6 has a good track record of being available and online, we don't closely monitor it (if something goes down, it could take us 24 hours or longer to address).

You should definitely set up and use a printing service on your own ArcGIS Server instance:  http://resources.arcgis.com/en/help/main/10.2/index.html#/Printing_in_web_applications/0154000004w50...
0 Kudos
ionarawilson1
Deactivated User
Thank you Derek! I will do that. I also found this video that might help :

http://video.esri.com/watch/1058/arcgis-for-server-101-printingtools-service-tutorial
0 Kudos