Posted by: Jeff Germain | January 20, 2010

Default draw symbology in the ESRI Flex Starter Kit

If you have used ESRI’s Flex Starter Kit you may have noticed an annoying feature when sketching graphics on the map via your custom widgets or their DrawWidget. When sketching a polygon, it requires 2 vertices before the sketch is drawn on the map. This only confuses your users as they are not sure their sketch has begun.

Anyways, it’s a simple fix… 2 lines of code. In MapManager::config() method, the Draw object is instantiated. Insert code to set default fillSymbol, lineSymbol, and markerSymbol. Here’s how:

drawToolbar = new Draw();

drawToolbar.map = map;            

drawToolbar.addEventListener(DrawEvent.DRAW_END, onDrawEnd);

// DTSAgile: Add default symbols so polygons are visible from first click when drawing

drawToolbar.lineSymbol = new SimpleLineSymbol("solid",0x333333, .8, 1);                    

drawToolbar.fillSymbol = new SimpleFillSymbol("solid", 0x333333, 0.15, new SimpleLineSymbol("solid",0x333333, .8, 1));                        

// drawToolbar.markerSymbol - add here...

// End DTSAgile edits

Note: This certainly isn’t limited to the ESRI Flex Starter Kit. This will occur anytime you try to draw a polygon using the Draw object and default symbols have not been set.

The likely culprit in all this is ESRI’s Flex API for Draw(). It does not seem to set the outline symbol for the fillSymbol. Thus, there is no area to fill until 2 vertices have been added to your sketch, and no outline symbol to show you where you started your sketch!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: