Tips and Tricks using GIS BigData, ArcGIS APIs and other fun stuff :-)

Sunday, February 22, 2009

Line Style With Arrows

A colleague of mine asked me if there was a way to put arrows at the end of drawn polylines. My answer was "Not out of the box directly :-( but you can create your own line style subclass :-) And here is an implementation in action. Check out the source code here.

I been working with your ArrowApp but when I bring up ArrowApp.html none of the arrow heads are placed properly. The arrow heads are not attached to the line as expected. If I zoom in or out on the map the arrow heads are again displayed incorrectly. The same problem occurs when I create a graphic programatically and set its symbol to an ArrowLineStyle object and add it to the GraphicsLayer. To get the arrow heads to display properly I have to pan the map or resize my browser window. When I view the hosted example you have everything shows up properly. I suspect you are using a previous version of the ESRI Flex library. I am using agslib-1.2-2009-05-15.swc. Any Ideas? Any help is appreciated.

Yeap - looks like there were mods to the final swc to make the sample not display the arrows at the correct location - try the following: public override function draw(sprite:Sprite, geometry:Geometry, attributes:Object, map:Map):void { super.draw(sprite, geometry, attributes, map); if (geometry is Polyline) { sprite.graphics.lineStyle(width, color, alpha); const polyline:Polyline = Polyline(geometry); for each (var path:Array in polyline.paths) { if (path.length > 1) { drawPath(sprite, path, map); } } } }Note how the super call is moved to the top ? hope this helps

Twitter Updates

About Me

BigData Advocate - Senior Software Architect at Esri - In addition to being part of the dev team, I travel the globe assisting customers implement BigData solutions with ArcGIS server - Cloudera Certified Hadoop Developer and HBase Specialist - When not coding, you will find me road biking in the middle of winter - went out the other day and was 8F - stay warm :-)