Click on PolylineData

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    29 posts
    Member since:
    Nov 2008

    Posted 29 Jun 2015 Link to this post

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


  2. Martin Ivanov
    Martin Ivanov avatar
    1448 posts

    Posted 02 Jul 2015 Link to this post

    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.

    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
Back to Top