I'd like to add the disclaimer "For reference only" to the scalebar. Do I need to customize my own adornment layer for this, or can I use the ScaleLineAdornmentLayer with some customizations?
Adding "For reference only" disclaimer to scalebar
Greg,
Example is coming right up.
David
Greg,
What we did was to inherit from the ScaleLineAdornmentLayer and override the DrawCore. In the DrawCore we add some code to draw the text and then call the base.DrawCore. This code only works for scale lines in the lower left corner and I would need to think about other positions. Anyway it is just a few lines of code so you can see what is going on.
David
public class ReferenceOnlyScaleLineAdornmentLayer : ScaleLineAdornmentLayer
{
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
{
ScreenPointF drawingLocation = this.GetDrawingLocation(canvas, 0, 0);
ScreenPointF newDrawingLocation = new ScreenPointF(drawingLocation.X + 43 , drawingLocation.Y - 35);
canvas.DrawText("For Reference Only", new GeoFont("Arial", 7,DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.StandardColors.Black), new ScreenPointF[] { newDrawingLocation }, DrawingLevel.LevelOne);
base.DrawCore(canvas, labelsInAllLayers);
}
}
Greg,
One other things. The ScaleLine stuff uses one method for computing screen distance on the map. The ScaleBar version uses another an for decimal degrees it seems to be more accurate. We have had customers call us on needing a bar that ‘really’ reflects the distance and we had to explain that in decima ldegrees there are trade offs between lat & long and accuracy etc. One thing that also comes up is DPI and we default to use a standard 96pdi I think. The best way to do the scalebar is to draw a reference line and then have the user measure it on their monitor. After that we can calculate the real DPI and add that to our calculation. Do you have any interest in seeing this as a code community project?
We also have a code community project that give you the entire code to a scale-bar that you can look at and enhance.
code.thinkgeo.com/projects/show/scalebar
David
Thanks for the offer, David. Luckily, at this time I think we can get away with the disclaimer…
Greg,
Great, let us know if you have any other questions.
David