I see the latest beta has a new object called Adornment Layer but I don't see any sample code on how to use it. Do you have any samples or information on how and what to use this for?
Thanks!
I see the latest beta has a new object called Adornment Layer but I don't see any sample code on how to use it. Do you have any samples or information on how and what to use this for?
Thanks!
Clint,
AdornmentLayers are used for things that draw on top of the map such as scale lines, scale bars, north facing arrows and other static items. Currently as we are in beta there is no documentation as of yet. We have a sample in “Moving around the Map” -> “CreateAScalelineAdornmentLayer” showing how to use an existing AdornmentLayer. If you want to create you own, here is some code to create your own TextLogoAdornment. Generally, you only need to override the DrawCore method to draw your logo (not just text, but also shapes and images) on top of every other layer to make it as an “Adornment”. Also for advanced developers, there are some other methods can be overridden to make the adornment more powerful and flexible. Just have a look and you can see how extensible it is. Ben.
//……
TextAdornmentLayer textAdornmentLayer = new TextAdornmentLayer();
mapEngine.AdornmentLayers.Add(textAdornmentLayer);
//……
class TextAdornmentLayer : AdornmentLayer
{
protected override void DrawCore(GeoCanvas canvas, GeographyUnit mapUnit, Collection<SimpleCandidate> labelsInAllLayers)
{
canvas.DrawTextWithScreenCoordinate("My Own Logo", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.StandardColors.Blue), 50, 10, DrawingLevel.LevelTwo);
}
}
Here is the result snapshot; you can see with a couple lines of code, I have my own logo on upper left.
Ben,
Thanks for the example that helped out a bunch but now I have ran into new issue I can’t get around.
How can I put the title inside of a Rectangle and center it on the top of the map? This will make the map title look very professional.
Thanks!
Clint.
Seems this is a good suggestion! We'll consider making some TitleAdornmentLayer which helps clients display the map titles. For now to implement it yourself, you can draw the rectangle and text in the DrawCore method of your own AdornmentLayer class. Here is the code and result.
Ben.
121-TestAdornmentForClint.txt (2.32 KB)