You can make a new Scalebar, copy it's attributes and place it in the footer or anywhere else on your map. You'd need create a new scalebar skin, which I have not done yet, but ESRI provides the current skins with the API, which is a big help. This is because you need to scale the scalebar to the print page size and just setting the height/width doesn't work. Granted, I have not gotten this far though, so not sure.To copy the scalebar, you can do something like this.
var i:uint = 0;
var x:uint = map.staticLayer.numChildren;
for (i; i < x; i++) {
trace("What is this object? {0}", map.staticLayer.getChildAt(i));
if (map.staticLayer.getChildAt(i) is ScaleBar) {
trace("found the scale bar!");
var s:ScaleBar = new ScaleBar();
s.map = (map.staticLayer.getChildAt(i) as ScaleBar).map;
s.lengthMetric = (map.staticLayer.getChildAt(i) as ScaleBar).lengthMetric;
s.lengthUS = (map.staticLayer.getChildAt(i) as ScaleBar).lengthUS;
s.textMetric = (map.staticLayer.getChildAt(i) as ScaleBar).textMetric;
s.textUS = (map.staticLayer.getChildAt(i) as ScaleBar).textUS;
// you can adjust the bottom/left/top/right values of the map scalebar too
s.bottom = 25;
s.left = 5;
this.addElement(s);
}
}
I copied the attributes of the scalebar, rather than copy it because if I do change the skin or figure out how to scale it, passing it would be reflected in the scalebar on the map, so make sure you copy it.That's as far as I've gotten so far. I'd love to hear some other solutions.edited, because yes, you can capture the scalebar, it's just tricky as Ricky showed above because of the size of the browser window.Ok, so I figured out how to move the scalebar before the image of the map is captured.
map.zoomSliderVisible = false;
map.addEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateComplete_handler);
var i:uint = 0;
var x:uint = map.staticLayer.numChildren;
for (i; i < x; i++) {
trace("What is this object? {0}", map.staticLayer.getChildAt(i));
if (map.staticLayer.getChildAt(i) is ScaleBar) {
trace("found the scale bar! left =", (map.staticLayer.getChildAt(i) as ScaleBar).left);
// move it into a position that works for you
(map.staticLayer.getChildAt(i) as ScaleBar).left += 200;
}
}
function onUpdateComplete_handler(e:FlexEvent):void {
map.removeEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateComplete_handler);
mapImage.source = PrintMapUtil.trimmedMap(map, mapImage.width, mapImage.height);
var j:uint = 0;
for (j; j < x; j++) {
trace("What is this object? {0}", map.staticLayer.getChildAt(j));
if (map.staticLayer.getChildAt(j) is ScaleBar) {
// move it back, 5 is the default
(map.staticLayer.getChildAt(j) as ScaleBar).left = 5;
}
}
map.zoomSliderVisible = true;
}
That's tested and works with PrintMapUtil and API2.0.
Well, that was fun, now back to work.