Performance in arcgis silverlight api

I use GraphicsLayer

for road signage with SimpleLineSymbol

. my code is the same with below code:

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

      

this code is fast, but drawing linesymbol on the map is very slow. (About 6 seconds). please help me to increase symbology performance.

+3


source to share


4 answers


I collect all the geometry into one polyline and create one graphic for it. then i create symbol and display. It takes one second to render and display on the 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);

      

+2


source


That's a lot of lines. One idea would be to reduce the number of lines to draw. You can check the zoom level or map scale and use this when defining lines to draw. For example, perhaps at a certain scale you only make certain roads, such as major roads. You can do this by adding an if statement to the loop that checks for the presence of a specific attribute (if it exists):



if (myGraphicsLayer.Graphics[i].Attributes["Type"] == "major") { }

      

0


source


Since you have a lot of features, performance will always be affected, although there are a few things to consider. Make sure you have the latest versions of Silverlight and the Esri API first, as performance improvements often appear in newer versions. Since you are rendering on the client, the characteristics of the host machine affect performance, and if you cannot take advantage of scalable rendering or object clustering, and you just use the main function symbol, then the only way to improve performance is to render the functions 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., although there are some workarounds for this,such as displaying pop-ups on hover. You can also easily implement click authentication.

0


source


You can split the task between threads to run in parallel 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();

      

0


source







All Articles