Select to view content in your preferred language

Graphics and Symbology

2785
19
02-10-2011 06:18 AM
JayKappy
Frequent Contributor
I have a feature set that I am quering.  Graphics are created and placed on the map using a predefined symbol.  Everything works great.
But I want to symbols to reflect the data....say they are police incidents.  I want a grpahic for Burglary, Car Accident etc etc.
What are my options here....do I apply an image to the graphic instead of a symbol? 
Keeping in mind that I want to also address speed...I dont want to be drawing tons of images etc.

Thoughts?

Thanks
0 Kudos
19 Replies
DominiqueBroux
Esri Frequent Contributor
It's exactly what the renderers are for.

You'll find sample here : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#RenderersXAML
0 Kudos
JayKappy
Frequent Contributor
Thanks...

So in that example I could do something like this if I wanted to shade it, Fill it, outline it etc.
<esri:UniqueValueInfo Value="Arizona" Symbol="{StaticResource MyRedFillSymbol}" />


But what if I wanted to symbolize the graphic with an image? Or some symbology that we are used to seeing in ArcMap....I know these wont work but just trying to understand here...

Tryign to find out the best way to step up the symbology to seomthing more represenitive of my data...like
ESRI symbology from ArcMap
Images that I create

That possible or wise?

<esri:UniqueValueInfo Value="Arizona" Source="/Assets/images/PushPin3.png"/>


<esri:UniqueValueInfo Value="Arizona" Symbol="{SOME ESRI SYMBOL}" />
0 Kudos
DominiqueBroux
Esri Frequent Contributor

That possible or wise?


Code:
<esri:UniqueValueInfo Value="Arizona" Source="/Assets/images/PushPin3.png"/>
Code:
<esri:UniqueValueInfo Value="Arizona" Symbol="{SOME ESRI SYMBOL}" />

The second syntax is the right one and you can use any symbols existing in the ArcGIS Silverlight client API.
To get an image as symbol, the PictureMarkerSymbol is what you need. There is a sample of pushpin symbol here :
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AddGraphicsXAML
0 Kudos
JayKappy
Frequent Contributor
Awesome....thank you....

one last question....Is there a location that I can go to and see all the available symbols existing in the Silverlight Client API?

Thanks again....
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The API documentation will give you the existing types of symbols : http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Symbols_na...

To get samples of symbols, you can look at the symbol gallery : http://help.arcgis.com/en/webapi/silverlight/samples/SymbolGalleryWeb/start.htm
0 Kudos
JayKappy
Frequent Contributor
I also noticed that the Renderer is workign on a Feature Layer....I have a grpahics layer and that does NOT like the WHERE clause

Thougths?

                <esri:FeatureLayer ID="MyFeatureLayerClassBreak"
                    Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0" 
                    Where="STATE_NAME in ('New Mexico', 'Arizona', 'Texas')" 
                    Renderer="{StaticResource MyClassBreaksRenderer}"
                    OutFields="POP1990"  />


                    <esri:GraphicsLayer ID="MyGraphicsLayerListBox1" 
                                        MouseLeftButtonDown="GraphicsLayer_MouseLeftButtonDown"
                                        MouseEnter="imageList1_Mousehover" 
                                        Visible="False" />


I am thinking that I might have to assign this in VB....each pass through the Loop assign the specific image based off the value??????

Yea I tried to set it using XAML and I dotn think that is going to work for me....as I am setting the symbol in VB...I tried to call the renderer in the exampel from VB and not working....
Do I have to set this up in VB?

        For Each selectedGraphic As Graphic In args.FeatureSet.Features
            selectedGraphic.Symbol = TryCast(LayoutRoot.Resources("StrobeMarkerSymbol_Blue"), ESRI.ArcGIS.Client.Symbols.Symbol)
            'selectedGraphic.Symbol = TryCast(LayoutRoot.Resources("MyUniqueValueRenderer"), ESRI.ArcGIS.Client.Symbols.Symbol)           
            _resultsGraphicsLayer.Graphics.Add(selectedGraphic)
        Next selectedGraphic



THINK I AM HAVING issues because its a graphics layer....Can I even do this on a graphics layer?
0 Kudos
DominiqueBroux
Esri Frequent Contributor

I also noticed that the Renderer is workign on a Feature Layer....I have a grpahics layer
THINK I AM HAVING issues because its a graphics layer....Can I even do this on a graphics layer?

Renderers are working with feature layers AND with graphics layers.


Do I have to set this up in VB?

If you set up a renderer on the layer, you don't have to set the symbols on the graphics by code.
0 Kudos
JayKappy
Frequent Contributor
I am doing this: and the app wont even open....Can you see anything...what am I missing....I was figuring that I would have to specify the symbol in the VB but from what you said I dont have to...as long as the Renderer is specified on the "GraphicsLayer"

I removed the line from teh VB that was setting the symbology...
selectedGraphic.Symbol = TryCast(LayoutRoot.Resources("StrobeMarkerSymbol_Blue"), ESRI.ArcGIS.Client.Symbols.Symbol)

With this my application will NOT open...so I have a big error somewhere....


            
    <Grid x:Name="LayoutRoot" Background="{StaticResource BaseColor}">
        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="BLUEMarkerSymbol" Color="Blue" Size="12" Style="Circle" />
            <esri:SimpleMarkerSymbol x:Key="PURPLEMarkerSymbol" Color="Purple" Size="12" Style="Circle" />
            
            <esri:UniqueValueRenderer x:Key="MyUniqueValueRenderer" Attribute="TYPE" >
                <esri:UniqueValueRenderer.Infos>
                    <esri:UniqueValueInfo Value="Church" Symbol="{StaticResource BLUEMarkerSymbol}" />
                    <esri:UniqueValueInfo Value="SCHOOL" Symbol="{StaticResource PURPLEMarkerSymbol}" />
                </esri:UniqueValueRenderer.Infos>
            </esri:UniqueValueRenderer>

        </Grid.Resources>

   <Grid Grid.Row="2">
        </esri:Map.Extent>
                <esri:Map.Layers>
                    <esri:GraphicsLayer ID="MyGraphicsLayerBufferResults" 
                                        MouseEnter="imageBuffer_Mousehover" 
                                        MouseLeftButtonDown="GraphicsLayerBuffer_MouseLeftButtonDown"
                                        Renderer="MyUniqueValueRenderer"
                                        >
                 </esri:Map.Layers>
        </esri:Map>



        _resultsGraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerBufferResults"), GraphicsLayer)        

        If args.FeatureSet.Features.Count < 1 Then
            MessageBox.Show("No features found")
            Return
            End If
        For Each selectedGraphic As Graphic In args.FeatureSet.Features

            _resultsGraphicsLayer.Graphics.Add(selectedGraphic)

        Next selectedGraphic



As Soon as I put this line in the GraphicLayer it bombs out

Renderer="MyUniqueValueRenderer"
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I suggest you add a default symbol to your unique value renderer, so we will know if the issue is coming from the values of your attribute 'TYPE'.
0 Kudos