This is a migrated thread and some comments may be shown as answers.

Best Practices for using Dynamic Layer

1 Answer 108 Views
Map
This is a migrated thread and some comments may be shown as answers.
Adnan
Top achievements
Rank 1
Adnan asked on 17 Apr 2012, 04:58 PM
Hi,

After encountering a few performance issues with the Dynamic Layer, would like some clarification on best practices of using the Dynamic Layer.

The following 2 forum posts are from 2010 - http://www.telerik.com/community/forums/wpf/map/working-with-dynamic-layers-and-mapshapereaders.aspx and http://www.telerik.com/community/forums/wpf/map/radmap-dynamiclayer-performance-problem.aspx

I am currently using the below code to only return those geometries which are in the current extents, rather then dealing with this at a fairly low level, does the Dynamic Layer have any of this functionality included?

Many thanks,

Adnan

public void ItemsRequest(object sender, ItemsRequestEventArgs e)
{
    IList<SqlGeometry> geometryList = new List<SqlGeometry>();
 
    LocationRect currentRegion = new LocationRect(e.UpperLeft, e.LowerRight);
 
    string sql = string.Format("SELECT the_geom FROM Locations WHERE the_geom.STIntersects(geometry::STGeomFromText('POLYGON(({0} {1}, {2} {3}, {4} {5}, {6} {7}, {0} {1}))', 0)) = 1 ", currentRegion.Southwest.Longitude, currentRegion.Southwest.Latitude, currentRegion.Northwest.Longitude, currentRegion.Northwest.Latitude, currentRegion.Northeast.Longitude, currentRegion.Northeast.Latitude, currentRegion.Southeast.Longitude, currentRegion.Southeast.Latitude);
 
    using (SqlConnection sqlConnection = new SqlConnection(connectionString))
    {
        sqlConnection.Open();
         
        using (SqlCommand sqlCommand = new SqlCommand(geographicalBoundsSQL, sqlConnection))
        {
            using (SqlDataReader reader = sqlCommand.ExecuteReader())
            {
                while (reader.Read())
                {
                    SqlGeometry sqlGeometry = (SqlGeometry)reader["the_geom"];
                    geometryList.Add(sqlGeometry);
                }
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 20 Apr 2012, 09:40 AM
Hello Adnan,

I think you use the right way for selecting geometries from database according to the requested region.
Mostly, the performance of dynamic layer depends on its ZoomGridList you will use in your application. The optimal value for the Latitudes and Longitudes count depends on the viewport size of the map control and the min zoom level of the zoom grid. I think that the dynamic layer will have best performance when the square size for request will be approximately equal to the viewport size.
The count could be calculated using the following way:
1. For example the viewport size is 1024x1024.
2. The map size is 512x512 when the zoom level is 1, 1024x1024 for 2 and 2048x2048 for 3 etc. The map size is calculated as 2 ^ (zoom level + 8).
3. When the zoom level is 3, then the count could be calculated as 2048 / 1024 = 2. I.e. count is calculated as map size/ viewport size.

I would recommend using the way of ZoomGridList calculation above for achieving good performance.

The dynamic layer adds/removes items dynamically. It works with squares which are calculated according to its ZoomGridList. When a square appears within the visible area of map then the dynamic layer adds its items onto the view. When a square gets out from visible area then the dynamic layer removes its items. During the panning a few squares can change its visibility. When squares contain a lot of figures (100 or more) then this process takes a long time.

Regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Map
Asked by
Adnan
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or