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

Use of ItemsRequestEventArgs

1 Answer 65 Views
Map
This is a migrated thread and some comments may be shown as answers.
Manfred
Top achievements
Rank 2
Manfred asked on 27 Jan 2011, 11:48 AM
Hi,

I am just new to this kind of coding and I have one question:
the example for adding dynamic layer is just the old version, so it doesn't show the use of ItemsRequestEventArgs.

Can you guys give me a hint how to use that in my code?
I added the class MapDynamicSource and modified ItemsRequest to
public void ItemsRequest(object sender, ItemsRequestEventArgs e)

But I have no idea how to call that.

Best regards
Manfred

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 01 Feb 2011, 09:20 AM
Hi Manfred,

The dynamic layer was redesigned in 2010.Q3 version. You can look at our online example which uses the new ItemsRequest functionality.
http://demos.telerik.com/silverlight/#Map/DynamicLayer

The ItemsRequestEventArgs contains all parameters which are required for requesting items. For example you have the following ItemsRequest which was designed for Q2 and new one:

public class DynamicSource : IMapDynamicSource 
    public void ItemsRequest(double minZoom, double maxZoom, Telerik.Windows.Controls.Map.Location upperLeft, Telerik.Windows.Controls.Map.Location lowerRight, Action<System.Collections.ICollection> callback)
    {
        // ...
    }
  
    public void ItemsRequest(object sender, ItemsRequestEventArgs e) 
    {
        //
    }
}

The parameters of the old ItemsRequest method could be obtained from the ItemsRequestEventArgs instance in the new request as the following way:
    minZoom = e.MinZoom
    maxZoom = e.MaxZoom
    upperLeft = e.UpperLeft
    lowerRight = e.LowerRight
Also the ItemsRequestEventArgs contains the CompleteItemsRequest method which you should use instead of the callback.

As a simple migration way you can change the code of dynamic source class to use a code which was designed for Q2 just using new delegate type instead of Action<System.Collections.ICollection> for callback. The sample code is below.

public class DynamicSource : IMapDynamicSource 
    // … 
    public delegate void CallbackDelegate(IEnumerable<object> items); 
  
    public void ItemsRequest(object sender, ItemsRequestEventArgs e) 
    
        this.ItemsRequest(e.MinZoom, e.MaxZoom, e.UpperLeft, e.LowerRight, e.CompleteItemsRequest); 
    
  
    // Q2 style items request 
    public void ItemsRequest(double minZoom, double maxZoom, Location upperLeft, Location lowerRight, CallbackDelegate callback) 
    
        List<object> objects = new List<object>(); 
        // … 
        callback(objects); 
    

Greetings,
Andrey Murzov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Map
Asked by
Manfred
Top achievements
Rank 2
Answers by
Andrey
Telerik team
Share this question
or