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

Exception with INotifyLocationChanged

5 Answers 107 Views
Map
This is a migrated thread and some comments may be shown as answers.
Etienne
Top achievements
Rank 1
Etienne asked on 25 Aug 2015, 04:18 PM

Hi,

I use INotifyLocationChanged to raise event when items of a VisualizationLayer move and it throws an exception in some particular case. I've joined a sample project that demonstrate this particular case. I'm I doing something wrong or this is a bug ?

Thank you,

Etienne

5 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 28 Aug 2015, 03:29 PM
Hi Etienne,

The reported error is caused by the fact that the LocationChanged event is raised for elements that are not added in the VisualizationLayer. In your case the layer with the zones always has two objects, however, the MoveForward command is changing the Location of all zones of all elements which throws an exception in the layer's code.

In order to prevent the error you will need to ensure that the LocationChanged event in your viewmodel is raised only if the model is added in the layer.

I hope this information is useful.

Regards,
Martin
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Etienne
Top achievements
Rank 1
answered on 28 Aug 2015, 05:41 PM

Hi Martin,

Thanks for your reply, but I'm not sure how I can do this elegantly. I would have expected that when an item is removed from a layer, the layer unsubscribe from the LocationChanged event or at least ignore future event.

Regards,

Etienne

0
Martin Ivanov
Telerik team
answered on 01 Sep 2015, 12:00 PM
Hi Etienne,

Since the event handler is manually attached you will need also to manually remove it from the object. However, we will take some time to investigate the observed behavior in the VisualizationLayer's code too. 

As for avoiding the exception, you can use different approaches based on your application's requirements. I updated your project to demonstrated a possible implementation which you can use. Basically, I defined a Boolean property in the MapItemViewModel that tells if the item has a parent (is it attached somehow to the layer) or not. Then, I am using the property in the condition for raising the LocationChanged event. I made few changes in the following files to set the property when the SelectedThing is changed and when the Things collection is populated:
  • MapItemViewModel.cs
  • ViewModel.cs
I commented the changed parts of the code. Please give the project a try and let me know if this approach works for you.

Regards,
Martin
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Etienne
Top achievements
Rank 1
answered on 11 Nov 2015, 03:30 PM

Hi Martin,

Is there any update on your side about this ?

Regards,

Etienne

0
Martin Ivanov
Telerik team
answered on 16 Nov 2015, 02:22 PM
Hello Etienne,

We investigate this and found out this is an issue in RadMap which we logged in our feedback portal. If you follow the item you will be notified as soon as there is any change in its status. We also updated your Telerik points as a small gesture of gratitude for reporting this to us.

Regards,
Martin
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Map
Asked by
Etienne
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Etienne
Top achievements
Rank 1
Share this question
or