Best Practices for using Dynamic Layer

2 posts, 0 answers
  1. Adnan
    Adnan avatar
    5 posts
    Member since:
    Jul 2011

    Posted 17 Apr 2012 Link to this post

    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);
                    }
                }
            }
        }
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 20 Apr 2012 Link to this post

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

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top