Select to view content in your preferred language

Movable scaled print area graphic

611
3
09-03-2010 03:11 PM
DanJensen
Deactivated User
All,
Here is the functionality I would like to implement:
When the user click the a button a scaled graphic appears in the center of the map above other graphics. The user could then pan and zoom in and out to make sure the entire area of interest is highlighted by the static graphic. When the user has it perfect, they click another button to send the highlighted area and associated print layout to the printer.

How can you make a graphic static so that pans and zooms change the area covered by the graphic?
Alternatively, can you move one graphic in the graphics layer so as to frame the area of interest?
The API Reference seems to hint this is possible:
geometry property (of the Graphic Class) 
geometry:Geometry 
The geometry that defines the graphic. If the geometry class is an IEventDispatcher, the Graphic will refresh itself when Event.CHANGE events on the geometry are thrown.  

I may be misinterpreting this, but wondered if this meant that geometry could somehow be bound to mouse moves and thus move the graphic with changes to the geometry.

How would you go about this?

Thanks,
-Dan
Tags (2)
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
Dan,

   Sounds like you want to look at the map.staticLayer
0 Kudos
DanJensen
Deactivated User
Robert,

That seems to do the trick.  I am still working on getting it scaled etc.

Not sure if using a graphic is possible or not, I could not get it to work.  I found it easier to add an image than a graphic.  I did this by creating an black rectangle image in MS Paint that fit would my approximate print area.  I added a button to my app that would toggle showing then hiding the print area image.  Then I used addElement or removeElement to show or hide the image.
map.staticLayer.addElement(image)
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dan,

  Here is what I did to use a graphic (Spark Primitive Graphic).

<fx:Declarations>
                 <s:Graphic id="mapOverlay">
   <s:Group>
    <s:Path id="mapOverlayPath" >
     <s:fill>
      <mx:SolidColor id="ovlayColor" color="0x000000" alpha="0.8"/>
     </s:fill>
    </s:Path>
   </s:Group>
  </s:Graphic>
</fx:Declarations>

//This code called from some function
mapOverlayPath.data = "M 0 0 v " + map.height + " h " + map.width + " v -" + map.height + " v -" + map.width + " M 100 100";
    mapOverlayPath.data += " v " + (map.height - 200) + " h " + (map.width - 200) + " v -" + (map.height - 200) + " Z";
    map.staticLayer.addElement(mapOverlay);
0 Kudos