4

I am using GraphicsLayer for road symbology with SimpleLineSymbol. my code is same with below code:

    for (int i = 0; i < 200000; i++)
    {
        myGraphicsLayer.Graphics[i].Symbol = mySimpleLineSymbol;
    }

this code run fast but draw linesymbol on map is very slow.(Approximately 6 sec). please help me for increase symbology performance.

Mohammad
  • 528
  • 4
  • 21
  • After this loop, do you have this layer's hidden flag set before you add it to your map? I'm thinking that you can leverage against the layer's update-end event during refresh(), where you can then call show(). { Note: I didn't have enough symbols in my application to investigate this approach, but you do }. – maurice Jan 04 '15 at 05:09

4 Answers4

3

I collect all geometry into one polyline and create one graphic for that. then i create symbol and display.It takes one second for rendering and display on map.

        var myPolyline = new ESRI.ArcGIS.Client.Geometry.Polyline();

        for (int i = 0; i < 200000; i++)
        {
            myPolyline.Paths.Add(((ESRI.ArcGIS.Client.Geometry.Polyline)myGraphicsLayer.Graphics[i].Geometry).Paths[0]);
        }

        Graphic myGraph = new Graphic();

        myGraph.Geometry = myPolyline;

        ESRI.ArcGIS.Client.Symbols.SimpleLineSymbol sym = new ESRI.ArcGIS.Client.Symbols.SimpleLineSymbol();

        sym.Color = new SolidColorBrush(Colors.Red);

        sym.Width = 2;

        myGraph.Symbol = sym;

        myGraphicsLayer.Graphics.Add(myGraph);
Mohammad
  • 528
  • 4
  • 21
0

That's a lot of lines. One idea would be to reduce the number of lines needing to be drawn. You could check the zoom level or scale of the map and use this in determining which lines to draw. For example, maybe at certain scales you only draw specific roads, such as major roads. You could do this by adding an if statement in the loop that checks for a particular attribute (assuming one exists):

if (myGraphicsLayer.Graphics[i].Attributes["Type"] == "major") { }
Kate
  • 1,556
  • 1
  • 16
  • 33
0

Since you have lots of features the performance is always going to be impacted though there are a few things to consider. First make sure that you have the latest versions of both Silverlight and the Esri API since there are often performance improvements in newer releases. Since you are rendering on the client then the specs of the host machine will affect the performance and if you can't take advantage of scale dependant rendering or feature clustering and you are just using a basic feature symbol then the only way to get better performance is to render the features on the server using ArcGIS Server and consuming them as a dynamic map service layer. This will mean that you won't be able to use maptips etc. though there are some workarounds for this such as showing popups on hover. You can also implement identify on click easily.

Dave Timmins
  • 331
  • 2
  • 6
  • For the reasons I have to do rendering on the client side, and I'm a bit limited. Is there a way that I know what time after the code execution is finished rendering? Is there an event in the GraphicsLayer for this? – Mohammad Dec 23 '14 at 12:17
  • You can try listening to the map progress event though I can't remember if that fires for graphics layers. Also, have you tried using a renderer instead of setting the symbol on each feature? That would be faster. – Dave Timmins Dec 23 '14 at 20:58
  • map progress event don't fire for Graphicslayers and i test renderer property instead of setting the symbol; it is slower than the set Symbol Property.i test SimpleRenderer and UniqueValueRenderer. – Mohammad Dec 24 '14 at 06:02
0

You can Divide task between Threads for parallel Working for better performance.

 new Thread(() =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    for (int j = 0; j < 50000; j++)
                    {

                        myGraphicsLayer.Graphics[j].Symbol = mySimpleLineSymbol;
                    }
                });

            }
).Start();


            new Thread(() =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    for (int k = 50000; k < 100000; k++)
                    {
                        myGraphicsLayer.Graphics[k].Symbol = mySimpleLineSymbol;
                    }
                });

            }
).Start();


            new Thread(() =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    for (int l = 100000; l < 150000; l++)
                    {
                        myGraphicsLayer.Graphics[l].Symbol = mySimpleLineSymbol;
                    }
                });

            }
).Start();


            new Thread(() =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    for (int m = 150000; m < 200000; m++)
                    {
                        myGraphicsLayer.Graphics[m].Symbol = mySimpleLineSymbol;
                    }
                });

            }
).Start();
Jawad Zeb
  • 523
  • 4
  • 18