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

Help with upperleft/right properties on a dynamic map layer

3 Answers 36 Views
Map
This is a migrated thread and some comments may be shown as answers.
Paul Grothe
Top achievements
Rank 1
Paul Grothe asked on 01 Aug 2013, 05:32 PM
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

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 02 Aug 2013, 10:20 AM
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 >>
0
Paul Grothe
Top achievements
Rank 1
answered on 02 Aug 2013, 12:18 PM
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.
0
Andrey
Telerik team
answered on 06 Aug 2013, 11:01 AM
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 >>
Tags
Map
Asked by
Paul Grothe
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Paul Grothe
Top achievements
Rank 1
Share this question
or