select polyline on map

7 posts, 0 answers
  1. jtby
    jtby avatar
    43 posts
    Member since:
    Feb 2007

    Posted 07 Jan 2014 Link to this post

    How can I detect if user has clicked on a polyline that has been added to the map?  I have tried the following, but the new mouse event does not fire when the user clicks on the polyline on the map:


    Me.polylineLayer.Items.Add(pline)

              

    pline.AddHandler(MouseLeftButtonDownEvent, New MouseButtonEventHandler(AddressOf pline_MouseLeftButtonDown))


  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 09 Jan 2014 Link to this post

    Hi John,

    It is not clear from your post what type of layer (InformationLayer or VisualizationLayer) you are using. But looking into your code I supposed that it is the InformationLayer. The problem is that you assign an event handler after you add a line to the information layer. Because of the nature of the map shape objects it must be done before you add a line to the information layer. The following code works as expected so please give it a try on your side as well:

    Imports Telerik.Windows.Controls.Map
     
    Class MainWindow
        Sub New()
     
            ' This call is required by the designer.
            InitializeComponent()
     
            ' Add any initialization after the InitializeComponent() call.
            Dim pline As New MapPolyline
            Dim points As New LocationCollection
            points.Add(New Location(10, -10))
            points.Add(New Location(-10, -10))
            points.Add(New Location(-10, 10))
            points.Add(New Location(10, 10))
            pline.Points = points
            pline.Stroke = New SolidColorBrush(Colors.Red)
            pline.StrokeThickness = 4
            AddHandler pline.MouseLeftButtonDown, AddressOf PolylineMouseLeftButtonDown
            Me.polylineLayer.Items.Add(pline)
     
        End Sub
     
        Private Sub PolylineMouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
            MessageBox.Show("Polyline clicked")
            e.Handled = True
        End Sub
     
    End Class

    Let us know if we can further assist you.

    Regards,
    Andrey Murzov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.

    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. jtby
    jtby avatar
    43 posts
    Member since:
    Feb 2007

    Posted 10 Jan 2014 Link to this post

    perfect, thanks!
  5. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 05 Jun 2014 Link to this post

    Hi,

    we have created a own Polyline object which inherits from the MapPolyline. Now we like get the coordinate where the user has clicked the polyline. 

    We like to create a polyline where a user could take the polyline and start moving it. Like a route in google maps where a user will add a new station. 

    Do you have any solution or idea? Is the polyline the right object?

    Thanks
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 06 Jun 2014 Link to this post

    Hi Simon,

    First of all, we don't recommend to inherit from the map shape objects classes (MapPolyline, for example), because it can have unpredictable result and brake functionality of the InformationLayer. 

    As for the polyline moving, it is not clear from you message how you suppose to move the polyline (the whole polyline or just one point of the polyline). Anyway, I would recommend you to take a look into the following resources:

    http://www.telerik.com/help/silverlight/radmap-howto-resize-map-shapes-with-mouse-dragging.html
    http://blogs.telerik.com/blogs/posts/12-01-09/radmap-for-silverlight-wpf-how-to-resize-map-shapes-with-mouse-dragging.aspx

    I hope it could help. 

    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.
     
  7. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 10 Jun 2014 in reply to Andrey Link to this post

    Hi Andrey,

    I know the examples and have test them but in my scenario it´s a little bit other. 

    You know google maps, if you have created a route then you will see the polyline of the route in the map. Now you could click everywhere on the polyline and drag the way to another place. (See startdrag.png and drop.png)

    Now we will create a control which could show in the map and get a notification if a user clicks the line (start and destination of the line are knowing) and starting drag&drop. If he drops the point we will start a operation. 

    Hope that this informations are helpful and you could get me some more tips. 

    Thanks
  8. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 10 Jun 2014 Link to this post

    Hi Simon,

    Unfortunately the RadMap does not contain built-in functionality which can serve your scenario. You can get geographical coordinates of the clicked point in the MouseLeftButtonDown event using following code:

    Location location = Location.GetCoordinates(radMap, e.GetPosition(radMap));
    But it is on your own to find the polyline segment this point belongs to, add new point and perform drag'n'drop operations on it.

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready