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

Disable HighlighFill on VisualisationLayer

1 Answer 31 Views
Map
This is a migrated thread and some comments may be shown as answers.
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Renier Pretorius asked on 29 Jul 2016, 11:41 AM

Hi,

I have a map with several Visualisation Layers. One of these represent nodes and another represents the links between the nodes. I want the user to select two nodes and then calculate the route along the links (these are not roads or other routes available through a map provider). Once I have determined all the links in the route I wish to select them. My links are LineData objects which have ShapeFill, SelectedFill and IsSelected properties. Initially I just wanted to set the IsSelected property but it is readonly so I am using the UseSelectedFill method that achieves the desired effect. However, as soon as the user hovers over the link it returns to the regular shapefill.

Is there a way to disable the highlighting event (while still shopwing the ToolTip) or is there an alternative aproach to take.

Regards

Renier

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 02 Aug 2016, 10:07 AM
Hello Renier,

You can set the AutoHighlightMapShape property of the VisualizationLayer to False.
<telerik:VisualizationLayer AutoHighlightMapShape="False">
Note that this property will disable the highlighting of all shapes in the visualization layer. If you want to forbid the highlighting of specific shapes only, you will need to write custom logic.

For example, you can subscribe for the MapShapeVisualizationCreated/Removed events of the VisualizationLayer and then subscribe for the MouseEnter event of the shape's presenter. After this you can override the default change of the fill. 
this.layer.MapShapeVisualizationCreated += layer_MapShapeVisualizationCreated;
this.layer.MapShapeVisualizationRemoved += layer_MapShapeVisualizationRemoved;
//......
void layer_MapShapeVisualizationRemoved(object sender, MapShapeOperationEventArgs e)
{
    e.Visualization.MouseEnter -= Visualization_MouseEnter;
}
 
void layer_MapShapeVisualizationCreated(object sender, MapShapeOperationEventArgs e)
{
    e.Visualization.MouseEnter += Visualization_MouseEnter;
}
 
void Visualization_MouseEnter(object sender, MouseEventArgs e)
{
    var presenter = (ContentPresenter)sender;
    var data = (MapShapeData)presenter.DataContext;
    if (data.IsSelected)
    {
        data.UseSelectedFill();
    }
    else
    {
        data.UseRegularFill();
    }
}

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Map
Asked by
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or