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

Click on PolylineData

1 Answer 121 Views
Map
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 2
Andrew asked on 29 Jun 2015, 05:10 PM

I'm using the VisualizationLayer to display PolylineData items. How can I detect if a PolylineData item has been clicked?

Andrew

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 02 Jul 2015, 02:40 PM
Hello Andrew,

You can get the clicked PolylineData in the MapMouseClick event handler of the RadMap control. Here is an example:
private void map_MapMouseClick(object sender, Telerik.Windows.Controls.Map.MapMouseRoutedEventArgs eventArgs)
{
    var itemsInLocation = this.layer.GetItemsInLocation(eventArgs.Location).OfType<PolylineData>();
    var clickedItem = itemsInLocation.Last();
}
I get the last item from the items in the clicked location because there could be several polylines. If so, there won't be clear which one is clicked. To determine that you can get the element with the highest ZIndex and if all have the same ZIndex you can get the last one in the collection. This will be the item that is at the top of the order stack of the visual tree.

As a side note, the GetItemsInLocation() method is located in the VisualizationLayer class.

Please try this approach and let me know if it 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
Tags
Map
Asked by
Andrew
Top achievements
Rank 2
Answers by
Martin Ivanov
Telerik team
Share this question
or