Hi.
I’m trying to add a title, legend and footer to the map using the LegendAdornmentLayer.
Once the map is resized using the browser window, the overlay is “regenerated” to re-center the text, however the font sizes remain the same.
Is there a way to scale the text on the graph when the window is resized?
Should I be using some other layer other than LegendAdornmentLayer to add these values to my map?
Adornment Layer rescale
Hi Maria,
I am not sure why you want to change the font size after resize map, but the LegendAdornmentLayer in web is get image from server side, so you can inherit LegendAdornmentLayer and override DrawCore to implement your logic.
To draw the values by yourself in map is hard I think.
Regards,
Don
Hi Don,
Thanks for the idea, however this doesn’t seem to actually work.
Debugging through it, the font size clearly changes on the resize, however the screen does not.
I’ve tried overriding
public class ResizableAdornmentLayer : LegendAdornmentLayer
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
{
this.Title.TextStyle.Font = new GeoFont(this.Title.TextStyle.Font.FontName, GetFontSize(canvas.Width, canvas.Height), this.Title.TextStyle.Font.Style);
base.DrawCore(canvas, labelsInAllLayers);
}
I’ve also tried overriding LegendItem, where I can also see the font size change has taken effect, but perhaps it’s getting cached?
Tahnks,
Maria
Hi Maria,
I think that maybe the reason.
You should want to disable client side cache and clear web side cache.
Regards,
Don
Hi Don,
I tried that. Disabling cache, clearing it, etc. in different browsers.
Does not seem to affect the font size once rendered. Plus disabling the cache is not really an option in the long run unless it can be done only for the map and not the overall application.
The only other thing I can think of is not calling base.DrawCore after setting the font size and do it explicitly, but then I would need to know how to actually output the text on the screen.
I’ve tried using canvas.DrawText but without much success.
Any suggestions?
Hi Maria,
In fact in our logic, we will create a tempGeoCanvas and draw legend on it, then draw the temp image to geocanvas.
Our developer haven’t used DrawText to draw.
I think maybe you can try that.
Regards,
Don