Anonymous
01-31-2003, 02:28 PM
I am creating an application in VB.net that uses the Mappoint com control. I need to be able to do 2 things:
1. Block the user from being able to select and move pushpins(separate tasks)
2. When a pushpin is moved, I need to know that it has moved, which pin it is, and what it's new location is. I do not know how to detect pin movement.
John Meyer
02-03-2003, 05:57 AM
Not sure if this will solve your problem but maybe it will help a little?
in the BeforeClick event you can set Cancel = True to cancel the users click. (either Right or Left Click)
This would disable the left mouse button on the map itself (prevent them from moving the pushpin) If you change it to Button =2 then you disable right click menu. If you remove the if statment and just leave Cancel = True you disable left or right click.
Private Sub MappointControl1_BeforeClick(ByVal Button As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long, Cancel As Boolean)
If Button = 1 Then
Cancel = True
End If
End Sub
Anonymous
02-03-2003, 09:45 AM
thank you so much. I appreciate your reply. I do have more questions, however. Is there any way to allow the user to select a pushpin, but prevent them from moving it? Also, How can I tell when a pushpin has been moved?
Thank you in advance
John Meyer
02-04-2003, 05:48 AM
Sonya,
There really is not an easy way to keep users from moving the pushpins that I know of.
You would have to come up with a cleaver way of doing it yourself. Off the top of my head I guess you could write code to check the position of pushpins against your database using the "AfterRedraw event" as a trigger, but depending of the number of pushpins your working with it may or may not be practical?
Manuel
06-05-2003, 12:50 PM
Try this:
Private Sub MPC_BeforeClick(ByVal Button As Long, ByVal Shift As Long,
ByVal X As Long, ByVal Y As Long, Cancel As Boolean)
On Error Resume Next
Set oResults = MPC.ActiveMap.ObjectsFromPoint(X, Y)
For Each oResult In oResults
If TypeOf oResult Is Pushpin Then
Cancel = True
...........
You only use "Cancel=True" if it is a Pushpin what you have selected
Anonymous
06-05-2003, 02:32 PM
I had an almost working method like what Manuel proposes. But then you have to account for double-clicking, overlapping pushpins, highlighting of pushpins, and other problems that escape my memory. I did go this route but went back. Moveable pushpins caused less problems that all the other issues.
Anonymous
06-09-2003, 05:37 PM
Try this:
Private Sub mapMain_SelectionChange(ByVal sender As Object, ByVal e As AxMapPoint._IMappointCtrlEvents_SelectionChangeEve nt) Handles mapVenders.SelectionChange
Dim sp As MapPoint.Shape
Dim loc As MapPoint.Location
Try
If TypeOf (e.pNewSelection) Is MapPoint.Pushpin Then
loc = mapVenders.ActiveMap.GetLocation(80, 0) 'get a location over at the north pole
sp = mapVenders.ActiveMap.Shapes.AddShape(MapPoint.GeoA utoShapeType.geoShapeRectangle, loc, 1, 1)
sp.Select()
sp.Delete()
End If
Catch e1 As Exception
'exit gracefully
End Try
End Sub
Basically what this will do is that every time you select a pushpin then this will create a small, barely noticeable shape over at the north pole, thus shifting the selection to that shape, and then it deletes it so no traces of what happened are left. This will effectively disallow the user from moving pushpins. If you want to leave the pushpin selected, you could try reselecting it with the e.pNewSelection instance, but I'm not sure if the movement will still be disallowed that way. Obviously this is the way that you will know which pushpin was moved, but again I haven't tried if it also has the new location with it. I'm using the method above and has always worked for me, so I guess you won't have any problems with it. Good luck and hope this helps you.