Select to view content in your preferred language

Marching Ant symbology for line

974
4
04-13-2011 05:47 AM
JayKappy
Frequent Contributor
Looking at an ESRI online example to make a line symboloze like marching ants....
I cant seem to reproduce it....I use the below code and the application just spins and never loads...
I know things work if I remove the RouteRender adn replace it with
<esri:SimpleLineSymbol x:Key="BlackLineSymbol" Color="Black" Width="2" Style="Dash" />
I get all the lines to draw....
I just cant seem to get the marching ants line to draw

Any thoughts? THanks

            <esri:SimpleRenderer x:Key="RouteRenderer">
                <esri:SimpleRenderer.Symbol>
                    <esri:LineSymbol>
                        <esri:LineSymbol.ControlTemplate>
                            <ControlTemplate>
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal">
                                                <Storyboard RepeatBehavior="Forever">
                                                    <DoubleAnimation BeginTime="0:0:0"
                                                       Storyboard.TargetName="Element" 
                                                       Storyboard.TargetProperty="StrokeDashOffset" 
                                                       To="1000" Duration="0:3:0" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <!--For polyline and polygon template, a Path element with the name "Element" is required-->
                                    <Path x:Name="Element" StrokeDashArray="2,1" StrokeDashOffset="0"
  Stroke="Green" StrokeThickness="5" />
                                </Grid>
                            </ControlTemplate>
                        </esri:LineSymbol.ControlTemplate>
                    </esri:LineSymbol>
                </esri:SimpleRenderer.Symbol>
            </esri:SimpleRenderer>

            <!-- =====Unique Value Renderer for Bus Routes.======================================================================= -->
            <esri:SimpleLineSymbol x:Key="Unknown" Color="Gray" Width="3" Style="Dash" />
            <esri:SimpleLineSymbol x:Key="BlackLineSymbol" Color="Black" Width="2" Style="Dash" />
            <esri:SimpleLineSymbol x:Key="Route783" Color="Blue" Width="4" Style="Dash" />

            <esri:UniqueValueRenderer x:Key="BusRouteUniqueRenderer" Attribute="STREETALL" DefaultSymbol="{StaticResource Unknown}">
                <esri:UniqueValueRenderer.Infos>
                    <esri:UniqueValueInfo Value="783" Symbol="{StaticResource Route783}" />
                    <esri:UniqueValueInfo Value="783_Downtown" Symbol="{StaticResource RouteRenderer}" />
                </esri:UniqueValueRenderer.Infos>
            </esri:UniqueValueRenderer>
            <!-- =========================================================================================== -->
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
<esri:SimpleRenderer x:Key="RouteRenderer">

RouteRenderer is defined as a renderer and then is used as a Symbol:

<esri:UniqueValueInfo Value="783_Downtown" Symbol="{StaticResource RouteRenderer}" />


Instead you should define a 'RouteSymbol' (with the line symbol inside your route renderer and then use this symbol in your 'BusRouteUniqueRenderer'
0 Kudos
JayKappy
Frequent Contributor
RouteRenderer is defined as a renderer and then is used as a Symbol:
 
Instead you should define a 'RouteSymbol' (with the line symbol inside your route renderer and then use this symbol in your 'BusRouteUniqueRenderer'


Alright that makes some sense...defining a renderer and using a symbol.....but was referecing this ESRI example
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ClosestFacility

So you are saying I can leave the majority of the code I have in the renderer but classify it as a RouteSymbol instead?  Losing you on this one....

THanks for your help adn thoughts

I can get the marching ants line to work with the existing Renderer above if I do this

                        <esri:FeatureLayer ID="MG_BusRoutes" Visible="False"
                                    Url="http://gis.logis.org/arcgis/rest/services/MG_Test/MapServer/9"
                                    Renderer="{StaticResource RouteRenderer}"/>

But then I dont have the UniqueRenderer......So I do see where you are coming from...the unique rendere is referncing a Symbol not a renderer....
Just confused on how to do what you said...its not that clear to me....I see that in the case above that is working for me that I am simply applying the renderer..and not the uniquerenderer where my problem exists....Renderer adn symbol..

Not really sure what your comment means

Tried to look up defining a RouteSymbol but no luck...uggggggg...so close yet so far away....at least I have the marching ants working...but need different colors.....

Thanks
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You have :
  1) To define your line symbol in your resource
                   <esri:LineSymbol x:Key="myLineSymbol">
                        <esri:LineSymbol.ControlTemplate>
                            <ControlTemplate>
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal">
                                                <Storyboard RepeatBehavior="Forever">
                                                    <DoubleAnimation BeginTime="0:0:0"
                                                       Storyboard.TargetName="Element" 
                                                       Storyboard.TargetProperty="StrokeDashOffset" 
                                                       To="1000" Duration="0:3:0" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <!--For polyline and polygon template, a Path element with the name "Element" is required-->
                                    <Path x:Name="Element" StrokeDashArray="2,1" StrokeDashOffset="0"
Stroke="Green" StrokeThickness="5" />
                                </Grid>
                            </ControlTemplate>
                        </esri:LineSymbol.ControlTemplate>
                    </esri:LineSymbol>


  2) To define your BusRouteRenderer by using symbols defined in your resources
<esri:UniqueValueRenderer x:Key="BusRouteUniqueRenderer" Attribute="STREETALL" DefaultSymbol="{StaticResource Unknown}">
                <esri:UniqueValueRenderer.Infos>
                    <esri:UniqueValueInfo Value="783" Symbol="{StaticResource Route783}" />
                    <esri:UniqueValueInfo Value="783_Downtown" Symbol="{StaticResource myLineSymbol}" />
                </esri:UniqueValueRenderer.Infos>
            </esri:UniqueValueRenderer>


  1) To use your BusRouteUniqueRenderer renderer in your featurelayer:
 
<esri:FeatureLayer ID="MG_BusRoutes" Visible="False" 
Url="http://gis.logis.org/arcgis/rest/services/MG_Test/MapServer/9" 
Renderer="{StaticResource BusRouteUniqueRenderer }"/>

0 Kudos
JayKappy
Frequent Contributor
Really appreciate the input....Man I was so close....

I tried to remove the SimpleRenderer a few times and just use the LineSymbol....everytime I did that all the crazy blue squiggly lines showed up telling my me syntax was shot.....
I just didnt add the x:Key="myLineSymbol"
As soon as I did that everything seems to be working....well havent tested yet but will soon...

Thanks again....much appreciated

Yep that was it.....I was confused when you said define a route symbol.....I thought I already had that....but in relaity I had it inside a renderer....simply remove the renderer and added the above line and bang...everything is working....

THANK YOU
0 Kudos