Dynamic Print Template
I would like to make the following enhancement to my print templates: If the scale is smaller than x, the overview map should be automatically hidden. The idea is that you only want to show an overview map if the extent is zoomed in, while in the case of printing a citywide map it is redundant, and detracts from the visual appeal of the map. I noticed that there is a scripting capability with the report designer. It seems one should be able to use this to test against the map scale and set the overview map visible property to false if appropriate. I'd need an example of syntax and also of which event this would want to fire on. Searching the site, it appears there is little or no documentation on this topic but figured its worth throwing it out there. Thanks.
-
Figured this out if anyone is interested. Here is the script:
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data;//script checks map scale and if it is a small scale map, hides
//the vicinity map as it is not needed.
public void Detail1_Format()
{
//get references to overviewmap and mapscale page elements
ARControl overviewmap = rpt.Sections["Detail1"].Controls["OverviewMap"];
TextBox mapscale = (TextBox )rpt.Sections["Detail1"].Controls["MapScale"];
//remove comma (if there is one) from scale text, so that it can be converted to an integer
string cleanscale = mapscale.Text.Replace(",", "");
//convert scale text to numeric value
int numScale = 0;
int.TryParse(cleanscale, out numScale);
//test current scale against scale threshold and set visibility of overview map accordingly.
if (numScale > 40000)
{
overviewmap.Visible = false;
}
}Pretty simple once I figured out how to get a reference to the different layout elements in the report. To make this work the overview map must be placed such that its absence does not look odd. I just moved it out of the legend area and into another corner of the map. If the scale is smaller than 1:40k, the overview map disapears, which still looks ok for the layout.
What I'd really like to do is provide the user with an interface for selecting which map elements they want and then use this technique to dynamically generate the map. This way they could choose legend, overview map, disclaimer, title, etc.... From what I can see, it does not appear like you can add fields to the print dialog though. I suppose this could be done as a workflow, but would rather stick with something closer to the default behavior.
0
Please sign in to leave a comment.
Comments
1 comment