简体   繁体   English

arcgis silverlight api的表现

[英]performance at arcgis silverlight api

I am using GraphicsLayer for road symbology with SimpleLineSymbol . 我正在使用GraphicsLayerSimpleLineSymbol进行道路符号系统。 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). 这段代码运行速度很快,但在地图上绘制linesymbol非常慢。(大约6秒)。 please help me for increase symbology performance. 请帮我增加符号系统性能。

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);

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语句来检查特定属性(假设存在一个):

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

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. 首先确保您拥有Silverlight和Esri API的最新版本,因为新版本中通常会有性能改进。 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. 由于您在客户端上进行渲染,因此主机的规格将影响性能,如果您无法利用与比例相关的渲染或特征聚类,并且您只是使用基本特征符号,那么获得更好性能的唯一方法是使用ArcGIS Server在服务器上呈现要素并将其作为动态地图服务图层使用。 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. 这意味着你将无法使用maptips等,虽然有一些解决方法,例如在悬停时显示弹出窗口。 You can also implement identify on click easily. 您还可以轻松实现点击识别。

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM