Select to view content in your preferred language

Setting symbol colors based on external data

2217
1
01-25-2011 05:42 AM
DonFreeman
Emerging Contributor
I would like to know if the following is possible or feasible. My map contains a point layer drawn from a Map service (not a feature service). There is a second table (Table2) which is associated with the point layer in a 1 to many relationship. The user clicks a point on the map and the related Table 2 records (usually 2) are shown in a datagrid below the map. The user can edit the records in Table2 to "claim" the point. If both of the records associated with a point have been claimed I would like to either remove the point from the map or display it with a different color symbol so that subsequent users will readily see that the point has been taken and it is no longer available for editing.

The technique I have in mind is on page load to iterate through the points and for each point to query Table2. If no records match the unclaimed criteria then the point symbol for that point would be changed indicating that it has been claimed. Does this sound like it would be a reasonable undertaking and if so could someone get me started on how to do it?
Thanks
0 Kudos
1 Reply
ScottFriedrich
Regular Contributor
One approach would be to define two symbols in xaml and assign them to the points as you iterate through them:

<!--Available-->
            <esri:MarkerSymbol x:Name="Available" x:Key="esriDefaultMarker_170" OffsetX="6.5" OffsetY="6.5">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid RenderTransformOrigin="0.5,0.5" Width="13" Height="13">
                            <Grid.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                </TransformGroup>
                            </Grid.RenderTransform>
                            <Canvas HorizontalAlignment="Left" VerticalAlignment="Top">
                                <Canvas.Clip>
                                    <EllipseGeometry RadiusX="6.5" RadiusY="6.5" Center="6.5,6.5" />
                                </Canvas.Clip>
                                <Ellipse Fill="#00FFFFFF" Stroke="Black" StrokeThickness="1" Width="13" Height="13" Canvas.Left="0" Canvas.Top="0" />
                                <Line Stroke="Green" StrokeThickness="2.5" X1="0" Y1="0" X2="13" Y2="13" />
                                <Line Stroke="Green" StrokeThickness="2.5" X1="0" Y1="13" X2="13" Y2="0" />
                            </Canvas>
                        </Grid>
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>

            <!--Not Available-->
            <esri:MarkerSymbol x:Name="NotAvailable" x:Key="esriDefaultMarker_171" OffsetX="6.5" OffsetY="6.5">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid RenderTransformOrigin="0.5,0.5" Width="13" Height="13">
                            <Grid.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                </TransformGroup>
                            </Grid.RenderTransform>
                            <Canvas HorizontalAlignment="Left" VerticalAlignment="Top">
                                <Canvas.Clip>
                                    <EllipseGeometry RadiusX="6.5" RadiusY="6.5" Center="6.5,6.5" />
                                </Canvas.Clip>
                                <Ellipse Fill="Yellow" Stroke="Black" StrokeThickness="1" Width="13" Height="13" Canvas.Left="0" Canvas.Top="0" />
                                <Line Stroke="Green" StrokeThickness="2.5" X1="0" Y1="0" X2="13" Y2="13" />
                                <Line Stroke="Green" StrokeThickness="2.5" X1="0" Y1="13" X2="13" Y2="0" />
                            </Canvas>
                        </Grid>
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>


Then when you iterate and determine if it's available or not, set the Symbol:

YourObject.Symbol = Available;


Hope that helps,

Scott
0 Kudos