Print map sample

4987
17
11-17-2010 10:45 AM
DominiqueBroux
Esri Frequent Contributor
For those who are interested, I just updated the print map sample.
A live version is still available here.

After refactoring the code, there are now separate components for:
- cloning a map (using an attached property)
- displaying the print grid (PrintOverviewLayer)
Combining these components gives more output possibilities just by changing the mapprinter style.
Example of output : WithLegend/WithOverview (in low definition pdf to reduce file size).
0 Kudos
17 Replies
DaveTimmins
Occasional Contributor II
Hi Dominique,

firstly, excellent example print. I've actually used a customised version of the previous sample for some work 🙂

I did notice a couple of minor issues.
The Now property doesn't update so if you format the data to show time it's always the same.

In the CloneMap Clone method, you aren't setting the Max/Min Resolution for GraphicLayer types.

toLayer.MinimumResolution = layer.MinimumResolution;
toLayer.MaximumResolution = layer.MaximumResolution;

Also in the same method you can save some processing by only cloning visible layers
i.e. foreach (var layer in mapToClone.Layers.Where(lyr => lyr.Visible && lyr.Opacity > 0.0))

Cheers,
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Dave,

Thanks for your comments.

I updated the sample to take care of your remarks and to remove the 'CurrentPageFillSymbol' property (use the 'Selected' state of the 'PageFillSymbol' instead)

Thanks.
0 Kudos
DaveTimmins
Occasional Contributor II
Hi Dominique,

thought I'd send my modified version in case you wanted to merge the additions. I've only attached the affected files (note that I've refactored the code to match my own coding style and I changed the namespace and deleted parts that I don't use).

The main additions are a dictionary that can be used for custom values to be output on the print. The Title property shows an example of this but I have used it in another project to insert a custom legend based on the symbols used for selections (the user could set a different symbol for each selection and then annotate that symbol for the legend). I also added 2 events, OnInitializingPrint and OnErrorPrinting. OnInitializingPrint can be used in conjunction with the dictionary described previously. OnErrorPrinting is self explanatory.

There is also a minor change in the CloneMap file.

Cheers,
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Dave,

Thank you very much for your additions. I will update the sample with them.

Just a question about the added dictionary: Isn't possible to get the same expected result by initializing the data context of the map printer with whatever the user wants (a dictionary being a particular case)?
Note that, I didn't really try this option, so there is possibly a blocking point somewhere:)
0 Kudos
DeminHu
New Contributor
I just want to say : thanks to all of your hard work, The sample  really helped me.
0 Kudos
DaveTimmins
Occasional Contributor II
Hi Dominique,

yes setting the DataContext seems to work great.

Cheers,
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Demin,

Thanks for your nice comments.
I am glad this helped you.
0 Kudos
LakshmananVenkatesan
Occasional Contributor II
Hi Folks:

Can you publish full solution for benifit of users. Thanks again

SR
0 Kudos
DaveTimmins
Occasional Contributor II
Hi,

the link to the code is at the top of the thread.

Cheers,
0 Kudos