Help with upperleft/right properties on a dynamic map layer

4 posts, 0 answers
  1. Paul Grothe
    Paul Grothe avatar
    26 posts
    Member since:
    Apr 2010

    Posted 01 Aug 2013 Link to this post

    How does the upperleft/lowerright properties get set from ItemsRequestEventArgs that is passed to the ItemsRequest() method of the IMapDynamicSource?

    I am seeing some behavior that I am not expecting.  I am using the dynamic map layer to reduce the amount of items displayed on the map by zoom level and region.  I have a zoom grid set with a minzoom of 10, and would like to set both the latitudescount and longitudescount to 50 or higher, however when I set it that high the upperleft property (which i use to get a reference to what the user is currently viewing on the map) gets set to a value that prevents the appropriate value from appearing on the map.

    For example, when debugging I will zoom into zoom level 10 and center at lat/long (45.00, -94.00), the upperleft property gets set to (44.92, 93.60), which is very close to the center screen and since I use that location to filter my data, it cuts off all the data that would normally appear in the upperleft part of the viewable map. 

    If I scroll the map up and to the left for a ways, it will load the data I want, then I can scroll back to the original position and see it.

    Am I not using this property correctly?  Or is there a better way to get a reference to the part of the map that is currently being viewed?

    Thanks
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 02 Aug 2013 Link to this post

    Hello Paul Grothe,

    When you use a collection of map objects then the standard way is in using the LocationRect structure. It has the Contains and Intersect methods which allow to check that the location or map shape is inside the requested area. For example when you have a location collection then you can return selected items the following way:
    private class DynamicSource : IMapDynamicSource
    {
        public List<Location> mapObjects = new List<Location>();
     
        public DynamicSource()
        {
            Random rnd = new Random();
            for (int i = 0; i < 100000; i++)
            {
                Location location = new Location(rnd.NextDouble() * 160 - 80, rnd.NextDouble() * 300 - 150);
                location.Description = i.ToString();
                mapObjects.Add(location);
            }
        }
     
        public void ItemsRequest(object sender, ItemsRequestEventArgs e)
        {
            LocationRect requestArea = new LocationRect(e.UpperLeft, e.LowerRight);
     
            var selected = from object mapObject
                               in mapObjects
                           where requestArea.Contains((Location)mapObject)
                           select mapObject;
     
            e.CompleteItemsRequest(selected);
        }
    }

    Also when you use data of point type then I would recommend to use the VirtualizationLayer. It requests data in background thread. It does not support map shapes, but it has better performance for data of point type.
    I have attached two sample solutions (for DynamicLayer and for the VirtualizationLayer).

    By the way, in the Q2 2013 release we've introduced new visualization engine in the RadMap.
    It has been designed from scratch to have better performance.
    The new engine is based on the VisualizationLayer class.
    Even the visualization layer has few good known lacks in the functionality (we are working on it actively) I would recommend you to give it a try.
    http://demos.telerik.com/silverlight/#Map/ClusterVirtualization
    http://demos.telerik.com/silverlight/#Map/AsyncReadWithVirtualization

    Regards,
    Andrey Murzov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Paul Grothe
    Paul Grothe avatar
    26 posts
    Member since:
    Apr 2010

    Posted 02 Aug 2013 Link to this post

    Thanks for the information, I will try using the virtualization layer to see if I get different results.

    I should point out though that that I beleive there may be a problem with the way the upperleft/lowerright properties are calculated.  The location rect that you are creating in your code example based on the upperleft/lowerright properties will exclude parts of the currently viewed area when using the example I mentioned above.
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 06 Aug 2013 Link to this post

    Hello Paul Grothe,

    In fact the dynamic layer also as the virtualization layer send as many request per visible area as needed to fill all grid cells which intersects with RadMap viewport. I.e. if your grid is configured so 4 grid cells intersects with visible area then 4 requests is sent. Every request has its own Upper-Left and Lower-Right corners.

    Regards,
    Andrey Murzov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top