Select to view content in your preferred language

Dynamic Legend, Multiple LayerList and Printing

1035
4
09-26-2010 02:16 AM
IanHamilton
Deactivated User
I have been trying to create multiple LayerLists in order to categorise my data into ISO categories, and using the Dynamic Legend from Robert to display the combined content of the LayerLIsts and printing (hoping that the legend would be printed too).

Initially I tried duplicating the widget with another name and config file (I got a a 2036 error - cannot load). Then I just created multiple config files with the one "instance" of LayerList. This indeed created multiple Layerlists with configurable content. So far so good.

To my great delight the Dynamic legend seems to be working in this scenario. (I am guessing it is because I have the More ... mapswitcher on?). My problem really comes when I want to print. The legend does not appear in the print.

I was wondering what could be done about this. Is there a way of converting the dynamic legend to a "static" legend (i.e. an image) in the print process?


Thanks in advance

Ian
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Ian,

   I will push out a new version with a public exportImage function soon but until then here is what you would need to add.

//New imports needed
import spark.primitives.BitmapImage;
import mx.graphics.ImageSnapshot;

//Add this new public function
   public function exportImage():BitmapImage
   {
    var bmpLegend:BitmapData = ImageSnapshot.captureBitmapData(legendDataGroup);
    var printImg:BitmapImage = new BitmapImage();
    printImg.smooth = true;
    printImg.source = bmpLegend;
    return printImg;
   }
//Also the LegendDatGroup needs an Id
<Legend:LegendDataGroup id="legendDataGroup" dataProvider="{legendAC}">
0 Kudos
IanHamilton
Deactivated User
Thanks Robert,

I am hoping to get into coding FLEX soon, so I have not yet been concentrating on it.

Am I right in thinking this code goes in your Legend and I'll need to call the function from a modified Print function somewhere?

I would also like to reduce the font/patch sizes in the legend. I couldn't find a setting for this.

It looks like I'll have to start looking at code much more!

Thanks again, Ian
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ian,

    Yes you are right on track with what you are trying to do. Let me tell you if you are not an experienced developer than what you are attempting is going to be very difficult. In ArcMap it is easy to add a legend, resize it, force new columns, etc. because it is an actual com object.
0 Kudos
IanHamilton
Deactivated User
Hi Robert,

In a previous life I was a developer but I don't underestimate what I might need to learn.

In any case if you are going to solve my legend problem that would be great!

I did notice some behavour of your legend that I though  you might like to know about.

If a layer list is opened first and then the legend no visible layers show up in the legend. I expect there is an event you could pick up for this or a list active layers you can access to initialise the legend?
0 Kudos