Select to view content in your preferred language

Error in Printing the map

2189
4
Jump to solution
02-13-2012 04:56 AM
Mohammed_YassineAYACHE
Occasional Contributor
Hi EveryBody !

I'm trying to create a widget for printing, like the one existing in the viewer. the problem is when I print the map, I get only a small part of it.

Attached the source code of the widget and a snapshot of the problem occured.

could you please show me what is wrong in my code ?

for your info, when I put the code of the function printMap() in the same file as the map (the main component), it works nice !
0 Kudos
1 Solution

Accepted Solutions
Mohammed_YassineAYACHE
Occasional Contributor
I think the problem is solved. I just changed these lines :
this.addElement(printBox); 

and
this.removeElement(printBox);


by :
this.parent.addChild(printBox);

and
this.parent.removeChild(printBox);


Attached the modified version of the test project if someone want to use it.

I'll be very thankful for any advise to improve this widget.

View solution in original post

0 Kudos
4 Replies
by Anonymous User
Not applicable
Original User: rscheitlin

Mohammed,

   I tested your code and got it to produce a whole map without changing anything... How are you calling the code you provided?

private var printWin:PrintWidgetWindow;
            private function showPrint():void
            {
                printWin = PopUpManager.createPopUp(this, PrintWidgetWindow,false) as PrintWidgetWindow;
                printWin.map = myMap;
                PopUpManager.centerPopUp(printWin);
            }
0 Kudos
Mohammed_YassineAYACHE
Occasional Contributor
Hi Robert,

I'm calling the printWidget within a toolsController like this :
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
   xmlns:s="library://ns.adobe.com/flex/spark" 
   xmlns:mx="library://ns.adobe.com/flex/mx">
 
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Map;
   
   import mx.events.CloseEvent;
   import mx.managers.PopUpManager;
   
   [Bindable]
   public var printWidgetOpen:Boolean = false;
   
   private var printWid:PrintWidget;
   
   public var map:Map;
   
   
   protected function hgroup1_rollOutHandler(i:Image):void
   {
    i.width = 30;
    i.height = 30;
   }


   protected function hgroup1_rollOverHandler(i:Image):void
   {
    i.width = 45;
    i.height = 45;
   }
   
   
   protected function printIcon_clickHandler(event:MouseEvent):void
   {
    if(!printWidgetOpen){
     printWid = PopUpManager.createPopUp(parent, PrintWidget,false) as PrintWidget;
     printWid.map = map;
     printWid.addEventListener(CloseEvent.CLOSE,printCloseHandler, false, 0, true);
     PopUpManager.centerPopUp(printWid);
     
     printWidgetOpen = true;
    }
    
   }
   
   protected function printCloseHandler(event:CloseEvent):void{
    printWidgetOpen = false;
   }
   
   
  ]]>
 </fx:Script>
 
 
 <s:BorderContainer width="20" height="160" cornerRadius="10" backgroundAlpha="0.8" backgroundColor="#333333" borderAlpha="0.9" borderColor="#222222" borderStyle="solid" borderVisible="true" borderWeight="3">
  <mx:VBox width="100%" height="100%" horizontalAlign="left" verticalAlign="middle">
   
   <!--Print Button-->
   <s:HGroup width="25" height="30"
       gap="2"
       horizontalAlign="left"
       verticalAlign="middle">
    
    <s:Line id="printLine" height="25"
      includeInLayout="{printWidgetOpen}"
      visible="{printWidgetOpen}">
     <s:stroke>
      <s:SolidColorStroke caps="square" color="#ede00a" weight="2"/>
     </s:stroke>
    </s:Line>
    
    <mx:Image id="printIcon" resizeEffect="Resize"
        width="30" height="30"
        buttonMode="true"
        smoothBitmapContent="true"
        useHandCursor="true"
        source="@Embed('assets/images/i_print.png')"
        click="printIcon_clickHandler(event)"
        toolTip="Impression"
        rollOut="hgroup1_rollOutHandler(printIcon)"
        rollOver="hgroup1_rollOverHandler(printIcon)"/>
    
   </s:HGroup>
   
   
  </mx:VBox>
 </s:BorderContainer>
</s:Group>



and the toolsController is called in the main component like this :
<widgets:ToolsController map="{mainMap}" left="30" bottom="60" />
0 Kudos
by Anonymous User
Not applicable
Original User: yassine.dev

I built a simple project to demonstrate the problem I have, it is attached to this post.

NB: when I execute this project using the Flex SDK 4.1, I get the problem described in my first post. and when I execute it with the SDK 4.6, I get the whole map printed but I don't get the copyright label !
0 Kudos
Mohammed_YassineAYACHE
Occasional Contributor
I think the problem is solved. I just changed these lines :
this.addElement(printBox); 

and
this.removeElement(printBox);


by :
this.parent.addChild(printBox);

and
this.parent.removeChild(printBox);


Attached the modified version of the test project if someone want to use it.

I'll be very thankful for any advise to improve this widget.
0 Kudos