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

select polyline on map

6 Answers 107 Views
Map
This is a migrated thread and some comments may be shown as answers.
jtby
Top achievements
Rank 1
jtby asked on 07 Jan 2014, 12:38 PM

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


6 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 09 Jan 2014, 08:52 AM
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 >>
0
jtby
Top achievements
Rank 1
answered on 10 Jan 2014, 12:00 PM
perfect, thanks!
0
Simon Störmer
Top achievements
Rank 1
answered on 05 Jun 2014, 01:09 PM
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
0
Andrey
Telerik team
answered on 06 Jun 2014, 11:18 AM
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.
 
0
Simon Störmer
Top achievements
Rank 1
answered on 10 Jun 2014, 09:26 AM
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
0
Andrey
Telerik team
answered on 10 Jun 2014, 12:09 PM
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.
 
Tags
Map
Asked by
jtby
Top achievements
Rank 1
Answers by
Andrey
Telerik team
jtby
Top achievements
Rank 1
Simon Störmer
Top achievements
Rank 1
Share this question
or