Print dijit fail using esri.geometry.Circle

2527
3
09-18-2014 10:37 AM
YvanBérard
Occasional Contributor

Hey guys,

I found that when using esri.geometry.Circle, the print dijit just fail to execute the task...

When using esri.geometry.Circle in a map graphic in this code :

var pt = new esri.geometry.Point(outputpoint[0].x,outputpoint[0].y,new esri.SpatialReference({ 'wkid': 4326 }));

  var sms = new esri.symbol.SimpleMarkerSymbol();

  sms.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_PATH);

  sms.setPath("M25.083,18.895l-8.428-2.259l2.258,8.428l1.838-1.837l7.053,7.053l2.476-2.476l-7.053-7.053L25.083,18.895zM5.542,11.731l8.428,2.258l-2.258-8.428L9.874,7.398L3.196,0.72L0.72,3.196l6.678,6.678L5.542,11.731zM7.589,20.935l-6.87,6.869l2.476,2.476l6.869-6.869l1.858,1.857l2.258-8.428l-8.428,2.258L7.589,20.935zM23.412,10.064l6.867-6.87l-2.476-2.476l-6.868,6.869l-1.856-1.856l-2.258,8.428l8.428-2.259L23.412,10.064z");

  sms.setColor(new esri.Color([255,0,0]));

  sms.setSize(32);

  var symbol = new esri.symbol.SimpleFillSymbol().setColor(null).outline.setColor([255,0,0]);

  var circle = new esri.geometry.Circle({

              center: pt,

              geodesic: true,

              radius: 450

            });

  // WORKAROUND TO MAKE THE PRINT DIJIT WORK

  /*var symbol = new esri.symbol.SimpleMarkerSymbol();

  symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE);

  symbol.setColor(null);

  symbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,new esri.Color([255,0,0]), 1));

  symbol.setSize(320);*/

  var arXY = esri.geometry.lngLatToXY(pt.x,pt.y);

  oMap.graphics.add(new esri.Graphic(pt,sms));

  oMap.graphics.add(new esri.Graphic(circle,symbol));

And if you print a map with a circle graphic, the print dijit just fail to execute and there is no way (I haven't found any) to capture the failed execution.

Here is the creation of the print dijit and all the  event attached to it.

var printer = new esri.dijit.Print({

  "map": oMap,

  "templates": templates,

  "async":true,

  url : oParamApp.urlArcServer+"ExportWebMap/GPServer/Export%20Web%20Map"

  }, dojo.byId("print_button"));

  printer.startup();

  console.clear();

  console.log(printer);

  printer.on('print-complete',function(){

  console.log('L\'impression est complétée.');

  });

  printer.on('error',function(){

  console.log('PRINT TIME-OUT ERROR');

  alert('Une erreur est survenue lors de l\'impression. \n\nVeuillez recommencer en désactivant des couches ou en redémarrant votre fureteur. \n\nSi le problème persiste, veuillez contacter la firme Jean-Pierre Cadrin & Ass. Inc.');

  });

  printer.on('print-start',function(){

  console.log('L\'impression a débuté.');

  });

  // NOT WORKING BUT EXIST IN THE DOM?!?!?

  printer.on('fail',function(){

  alert('execution failed');

  });

As you can see, this is my FireBug console...

print_dijit_exec_failed.png

Is there a way to capture that kind of error/failure from the dijit?

Or is there a way to correct the API so we can print graphic esri.geometry.Circle?

For now, I'm using a workaround using a point...

Thanks for your help.

0 Kudos
3 Replies
RiyasDeen
Occasional Contributor III

Hi Marc,

Try removing, async: true, I can simulate an error in ArcGIS API for JavaScript Sandbox  by just adding async true.

Untitled.png

0 Kudos
YvanBérard
Occasional Contributor

Well in my case, if I comment the line async: true, the print dijit just crash...So I need it to make it work.

If you want my opinion, the print dijit is just....well not really a good dijit...ESRI should re-code/ redevelop it.

0 Kudos
RiyasDeen
Occasional Contributor III

Hi Marc,

Is your print task execution mode set to asynchronous? May be try setting it to synchronous mode and try the print widget.

0 Kudos