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

VisualizationLayer and MapShapeFill

1 Answer 111 Views
Map
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 11 Jun 2014, 09:07 PM
I have the ItemsSource of a VisualizationLayer bound to a collection of LineData.  I have the MapShapeFill of the VisualizationLayer bound and it is used by the VisualizationLayer when first rendering the collection of LineData.  If I change the property MapShapeFill is bound to, the VisualizationLayer picks up this change; however, the rendered LineData does not re-render (this is somewhat expected).  However, if I remove that VisualizationLayer and create a new VisualizationLayer and set its ItemsSource to the same collection of LineData, it still uses the old MapShapeFill (as was initially set on the original layer), which seems to suggest that the RadMap is holding on to the controls it creates for this collection of LineData even if the VisualizationLayer is removed. 

So, I have to create a new collection of LineData in order for the new MapShapeFill to be applied.

Is there anyway to get a VisualizationLayer to apply a new MapShapeFill to its ItemsSource (i.e. the collection of LineData) without generating a new ItemsSource?

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 16 Jun 2014, 01:48 PM
Hi John,

All things work as expected. The visualization layer do not bind own map shape filling properties (ShapeFill, HighlightFill, SelectedFill) to the correspondent properties of the map shapes. It just copy values of these properties to the just added shapes which have not own properties set. So when you change value of the ShapeFill property of the VisualizationLayer object it doesn't change filling of the map shapes in the layer.

When you create new layer and add map shapes there the values of the filling properties will not be used because they are set already for all map shape data.

You need not to create new visualization layer or new collection of the shapes. All what you have to do is walk through your collection and change value of the LineData,ShapeFill property to the desired value. For example:

private void ChangeShapeFill(IEnumerable<MapShapeData> shapes, MapShapeFill newShapeFill)
{
    foreach (MapShapeData shape in shapes)
    {
        shape.ShapeFill = newShapeFill.Clone();
        shape.UseRegularFill();
    }
}



Regards,
Andrey Murzov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Map
Asked by
John
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or