Select to view content in your preferred language

Legend for CartographicLineSymbol

1223
2
07-27-2010 01:15 AM
Ganael_Jatteau
Emerging Contributor
Hi,

I have a map with some CartographicLineSymbol on a graphic layer and I'm trying to build a legend.

I tried 2 solutions to draw a line symbol into an UIComponent but none of them works.

Solution 1:
var uic:UIComponent = symbol.createSwatch(20,15);


Solution 2:
var uic:UIComponent = new UIComponent();
uic.width = 20;
uic.height = 15;
var polyLine:Polyline = new Polyline();
var p1:MapPoint = new MapPoint(0,0);
var p2:MapPoint = new MapPoint(15,0);
var path:Array = new Array(p1,p2);
polyLine.addPath(path);
symbol.draw(uic, polyLine, null, this._map);


The line symbol has a width, a color. Any idea how to solve that problem?

Thanks!
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Ganael,

    Most cartographic lines use composite symbols and the documentation for the createswatch states
Creates a swatch for a symbol which can be used in a legend. Swatches only work with symbols which are supported in the FeatureService, i.e., swatches are not supported for CompositeSymbol, InfoSymbol and TextSymbol.
as far as it not working for the Symbol.draw method I don't know why that is not working.
0 Kudos
SarthakDatt
Frequent Contributor
Hey Ganeal,

This works for me:

<?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" 
    minWidth="955" minHeight="600" 
    creationComplete="application1_creationCompleteHandler(event)">

    <fx:Script>
        <![CDATA[
            import com.esri.ags.symbols.CartographicLineSymbol;
            
            import mx.events.FlexEvent;
            
            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {
                var sym : CartographicLineSymbol = new CartographicLineSymbol("solid", 0xFF0000, 1, 5, CartographicLineSymbol.CAP_ROUND);
                vgrp.addElement(sym.createSwatch(50, 50));
            }
       ]]>
    </fx:Script>

    <s:VGroup id="vgrp" paddingTop="100" paddingLeft="500">
        <s:Label text="Cartographic swatch test"/>
    </s:VGroup>
</s:Application>


Let me know if you still can't get it to work.

-- Sarthak Datt
ESRI Flex Team
0 Kudos