Select to view content in your preferred language

Super Easy Point Graphic

957
7
10-07-2010 02:21 PM
DavidAshton
Frequent Contributor
All I'm doing is using the spatial tools from the SDK and I'm trying to code it to work with Points.  I can get the table to populate to work but the points don't select....the graphic symbol is still set for fill or line.  Where shold I change this?  I think it is here: but not sure what to put.


GraphicsLayer graphicsLayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;

            if (featureSet != null && featureSet.Features.Count > 0)
            {
                foreach (Graphic feature in featureSet.Features)
                {
                    feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol;
                    graphicsLayer.Graphics.Insert(0, feature);
                }
            }




AND/OR HERE



  public MainPage()
        {
            InitializeComponent();
            ResourceDictionary rd = Application.Current.Resources;
            levelGreaterThanBrush = rd["levelGreaterThanBrush"] as SolidColorBrush;
            levelLessThanBrush = rd["levelLessThanBrush"] as SolidColorBrush;
            levelEqualsBrush = rd["levelEqualsBrush"] as SolidColorBrush;
            ribbonElementBackground = rd["RibbonElementBackground"] as LinearGradientBrush;
            ribbonElementBackgroundHighlight = rd["RibbonElementBackgroundHighlight"] as LinearGradientBrush;

            _drawSurface = new Draw(Map)
            {

              //  FillSymbol = LayoutRoot.Resources["DefaultPointSymbol"] as SimpleMarkerSymbol,
                LineSymbol = LayoutRoot.Resources ["DefaultLineSymbol"] as SimpleLineSymbol,
               FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as FillSymbol
                
            };
            _drawSurface.DrawComplete += MyDrawSurface_DrawComplete;

            _queryTask = new QueryTask("http://dgpdch01/ArcGIS/rest/services/CAD/MapServer/0");
            _queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            _queryTask.Failed += QueryTask_Failed;
        }






0 Kudos
7 Replies
JenniferNery
Esri Regular Contributor
I don't know if I understood your question so please correct me if I'm wrong.

Your GraphicsLayer contain graphics with point geometry and is unable to select the features with point selection?  Have you looked at these two examples?
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SelectGraphics
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerSelection

What I suspect could be happening is that the graphic is selected but you do not change its Selected property to true. If you are using the Editor (as in the second sample), you do not need to set this property.
0 Kudos
DavidAshton
Frequent Contributor
Jennifer,
Thanks for the reply, I'm sorry I didn't explain myself good enough for you to understand.
I'm using the example
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SpatialQuery
it works great when I set it up to select a polygon layer but if I change it to a point layer the point doesn't select or the graphic point isn't placed on the point that was spatially queried. 

Dave
0 Kudos
BrianPangtay
Regular Contributor
Your code has the "DefaultPointSymbol" commented out. That is the symbol you need to be using for point-type geometry.
0 Kudos
DavidAshton
Frequent Contributor
Your code has the "DefaultPointSymbol" commented out. That is the symbol you need to be using for point-type geometry.


bpangtay, thanks for the reply.  I was trying to figure out what to write that's why it is commented out.  If that is all I need what do I write because that code causes errors.

   //  FillSymbol = LayoutRoot.Resources["DefaultPointSymbol"] as SimpleMarkerSymbol,

the FillSymbol seems like it should be MarkerSymbol?????
0 Kudos
BrianPangtay
Regular Contributor
Assuming that you just want to show the points from a query, the code to modify is:

feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol;

to

feature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol;

You will also need a resource defined under <Grid.Resources> in the XAML such as

<esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Red" Size="12" Style="Circle" />

The DRAW class is being used just to graphically display the selection methods interactively (via lines and polygons) which is why it doesn't take marker symbols.
0 Kudos
DavidAshton
Frequent Contributor
Brian thanks for all the replies and the help. 

I've always had this in my xaml.  It was one thing I knew how to add
<esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Red" Size="16" Style="Circle" />

I was trying to add to the draw class and not the QueryTask_ExecuteCompleted method.

Adding

feature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as SimpleMarkerSymbol;

To the QueryTask_ExecuteCompleted method worked

Thanks
0 Kudos
JMcNeil
Deactivated User
David,

To get table rows to interact with your graphics.... hover a row and it changes the color of the graphic and to get your graphic to change colors when you mouseover ......right now I bet it just gets slightly bigger. 

Your first post sounded like you wanted the points to respond like the polys did....like the sdk example.

I think your xaml is:
<esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Red" Size="16" Style="Circle" />


Add this in its place and the mouseover graphic change should and when you hover a row in the table your point graphic will change color



 <esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol"  >
            <esri:SimpleMarkerSymbol.ControlTemplate>
                <ControlTemplate>
                    
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="Element"
                                                        
                                                 Storyboard.TargetProperty= "(Fill).(Color)"
                                                To="#FFF5FF45" Duration="0:0:0.1" />
                                        </Storyboard>

                                    </VisualState>

                                        <VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="Element"
                                                Storyboard.TargetProperty="(Fill).(Color)"
                                                To="#8800FFFF" Duration="0:0:0.1" />
                                            </Storyboard>
                                        </VisualState>
                                    
                                        <VisualState x:Name="Selected">
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="Element"
                                                Storyboard.TargetProperty="(Fill).(Color)"
                                                To="#8800FFFF" Duration="0:0:0.1" />
                                            </Storyboard>
                                        </VisualState>
                                    
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>

                                <Ellipse x:Name= "Element"             
                                               Stroke="Blue" Fill="#880000FF"
                                StrokeStartLineCap="Round" StrokeThickness="2" 
                                StrokeLineJoin="Round" StrokeEndLineCap="Round"    
                                     Width="16"                 
                                     Height="16"                    
                                                    
                                      />

                            </Grid>
                       
                    </ControlTemplate>
            </esri:SimpleMarkerSymbol.ControlTemplate>
            </esri:SimpleMarkerSymbol>



0 Kudos