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

How to know the current objects designed in dynamic layer

2 Answers 54 Views
Map
This is a migrated thread and some comments may be shown as answers.
Pedro
Top achievements
Rank 1
Pedro asked on 19 Oct 2010, 05:37 PM
Hi,

I'm using dynamic layer to draw location points on map, and when I delete a current object and next try to draw it again throws ArgumentException when calling.

callback(objects)

This callback is the callback of the function itemsrequests(). I think that is crashing because the object is already in the dynamic layer. 
Is there a way to test if the object is already in Dynamic layer. Or what can cause this exception. 


I really need your help I can't find a sollution.

Kind regards,
Gonçalo

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 21 Oct 2010, 12:57 PM
Hi Gonçalo,

You can use the Contains method of the DynamicLayer.Items object to check that the item is already in the layer.

List<object> objects = new List<object>();
if (!page.DynamicLayer.Items.Contains(itemToAdd)) 
{
 objects.Add(itemToAdd);
}
  
callback(objects);

Another cause of the ArgumentException with the "Value does not fall within the expected range" error could be in using the Name property of MapShape objects (MapPolyline, MapPolygon etc).
When you use the Name property then it is still registered in visual tree although it has been removed from the layer. And when you add the map polyline second time then the exception is thrown.

We have created a PITS issue to fix this problem in future releases.
You can track it using the following link:
http://www.telerik.com/support/pits.aspx#/public/silverlight/3789

In this case as workaround use the map polylines without using the Name property or use the Tag property instead.

Greetings,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pedro
Top achievements
Rank 1
answered on 21 Oct 2010, 03:08 PM
Thanks Andrey :)

It was the name. Now it works fine.
:)

Kind regards,
Gonçalo
Tags
Map
Asked by
Pedro
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Pedro
Top achievements
Rank 1
Share this question
or