VisualizationLayer and MapShapeFill

2 posts, 0 answers
  1. John
    John avatar
    7 posts
    Member since:
    Apr 2014

    Posted 11 Jun 2014 Link to this post

    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?
  2. Andrey
    Andrey avatar
    1681 posts

    Posted 16 Jun 2014 Link to this post

    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();

    Andrey Murzov
    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.
Back to Top