Select to view content in your preferred language

GraphicsLayer not appearing V2.4

817
5
05-09-2012 05:56 AM
bayramüçüncü
Deactivated User
Hi,
I am using Esri Silverlight API v2.4.
An application that is working on v2.2, but not working v2.4. The problem is about Esri GraphicsLayer.

  private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            FeatureSet featureSet = args.FeatureSet;

            if (featureSet != null && featureSet.Features.Count > 0)
            {
               
                Graphic selectedFeature = featureSet.Features[0];

                selectedFeature.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol;

                graphicsLayer.Graphics.Add(selectedFeature);

                ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent;

                double expandPercentage = 30;

                double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100);
                double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100);

                ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
                selectedFeatureExtent.XMin - (widthExpand / 2),
                selectedFeatureExtent.YMin - (heightExpand / 2),
                selectedFeatureExtent.XMax + (widthExpand / 2),
                selectedFeatureExtent.YMax + (heightExpand / 2));

                MyMap.ZoomTo(displayExtent);
            }

        }

This code zoom and paint the area of the polygon. Zoom is working fine, but paint is not working.
I have debugged project and selectedFeature.Symbol is not null, everything is normal, but SimpleFillSymbol is not applied. and not appearing on the Map
0 Kudos
5 Replies
HyrumErnstrom
Regular Contributor
Check the RendererTakesPrecedence variable on the GraphicsLayer.

If RendererTakesPrecedence is set to true the Symbol can only be obtain through the Renderer.GetSymbol.
0 Kudos
JenniferNery
Esri Regular Contributor
I assume the symbol you are using fits the type of geometry (i.e. FillSymbol for Polygon). Also, if the same code works in v2.2 and behaves differently in v2.4, it could be the auto-project. You are probably zooming now to an extent that does not match your map's extent since the feature.geometry was auto-projected.
0 Kudos
bayramüçüncü
Deactivated User
Check the RendererTakesPrecedence variable on the GraphicsLayer.

If RendererTakesPrecedence is set to true the Symbol can only be obtain through the Renderer.GetSymbol.


I tried the change RendererTakesPrecedence property true and false but not wroking
<esri:GraphicsLayer ID="MyGraphicsLayer" RendererTakesPrecedence="True"/>

If I change the reference of the ESRI dll, from 2.4 to 2.2, the graphics are rendering. I think this is about v2.4. Or this problem is about the arcgis 10.
Before I couldn't zoom the selected feature, and I read a post in this forum, If you use arcgis server 10 version, you should set query.ReturnGeometry = true;
Because arcgis 9 returns geometry but 10 not.
After I solved this problem, this problem(graphicslayer problem) occured.
0 Kudos
JenniferNery
Esri Regular Contributor
Do you perform your query with OutSpatialReference same as the Map's SpatialReference? Does the result contain geometry and does it match the map's? RendererTakesPrecedence would only make a difference if you have graphic.Symbol as well as Renderer defined. But if graphic is added without symbol or your layer has no Renderer then changing this has no effect. Are you able to repro the issue by using one of the sample servers using ArcGIS 10? Can you share some code or explain the order of when you do your query, what parameters are set and what layers are on your map? Thanks.
0 Kudos
bayramüçüncü
Deactivated User
Do you perform your query with OutSpatialReference same as the Map's SpatialReference?

Thanks Jennifer,
This question is answer of my question. While querying, I assigned the Map's spatialReference to Query's SpatialReference, and the graphics worked fine. Because the Map's spatialReference is different from Query layer spatial reference.
0 Kudos