Has anybody had success skinning the scale bar? When I try to create a new MXML Skin as a copy of com.esri.ags.skins.ScaleBarSkin, I get the error: "The source for the skin "{0}" cannot be found."
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags"> <s:layout> <s:VerticalLayout horizontalAlign="center"/> </s:layout> <esri:Map id="map" scaleBarVisible="false"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> </esri:Map> <esri:ScaleBar map="{map}"/> </s:Application>
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); } }
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.
did you have any luck? I'm hoping to print to scale using flex too
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.