Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

Detecting when a line is clicked on in MP2K

This is a discussion on Detecting when a line is clicked on in MP2K within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have a series of pickup/drop off address pairs. I make a pushpin for pickup and one for dropoff, and ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Detecting when a line is clicked on in MP2K

    I have a series of pickup/drop off address pairs. I make a pushpin for pickup and one for dropoff, and draw a line between them.

    I have written a mousedown even that is able to detect if a pushpin is clicked, but I don't seem able to see if the line between them has been clicked on. What I want to be able to do here is process the some code if they click on either pushpin OR the line connecting them. TIA.


    Dim oMap As MapPointCtl.Map
    Dim oResults As MapPointCtl.FindResults
    Dim oResult As Object

    On Error Resume Next
    Set oMap = Form1.MappointControl1.ActiveMap
    Set oResults = oMap.ObjectsFromPoint(X, Y)
    For Each oResult In oResults
    if Left(oResult.Name, 2) = "PU" or _
    Left(oResult.Name, 2) = "DO" Then
    <code here to process the Pickup or Dropoff>
    Next

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Put the getItemType Function in a Module

    In a CommandButton you could call the function like this: (with an item on the map selected!)
    Code:
    Dim objmap As MapPointCtl.Map
    Set objmap = MappointControl1.ActiveMap
    MsgBox GetItemType&#40;objmap.Selection&#41;
    from within the SelectionChange event:
    Code:
    MsgBox GetItemType&#40;pNewSelection&#41;
    Code:
    Function GetItemType&#40;ByVal iSelection As Object&#41;
    
    On Error GoTo error&#58;
     
    If TypeOf iSelection Is Pushpin Then
    GetItemType = "Pushpin"
    Exit Function
    End If
     
    If TypeOf iSelection Is Location Then
    Set objLoc = iSelection
        Select Case objLoc.Type
            Case "-1"
                GetItemType = "Road, Street Address, or Other"
            Case "8"
                GetItemType = "City"
            Case "17"
                GetItemType = "Region2"
            Case "18"
                GetItemType = "Region1"
            Case "19"
                GetItemType = "Country"
            Case Else
                GetItemType = "Location Type&#58; " & objLoc.Type
        End Select
    
    'There are more of these but the most common is US are here
    Exit Function
    End If
     
     
    If TypeOf iSelection Is Waypoint Then
    Dim objWayPoint As MapPointCtl.Waypoint
    Set objWayPoint = iSelection
    
    Select Case objWayPoint.Type
        Case "1"
            GetItemType = "Waypoint type&#58; geoWaypointStart &#40;Start of Route&#41;"
        Case "2"
            GetItemType = "Waypoint type&#58; geoWaypointStop &#40;Intermediate stop&#41;"
        Case "3"
            GetItemType = "Waypoint type&#58; geoWaypointEnd &#40;End of Route&#41;"
        End Select
    Exit Function
    End If
    
    If TypeOf iSelection Is Route Then
    GetItemType = "Route"
    Exit Function
    End If
    
    Dim obj1 As MapPointCtl.Shape
    Set obj1 = iSelection
     
    Select Case obj1.Type
        Case Is = "1"
            Select Case obj1.AutoShapeType
            Case "1"
                GetItemType = "Rectangle"
            Case "9"
                GetItemType = "Oval"
            Case "1009"
                GetItemType = "Circle based on a radius"
            End Select
            
        Case Is = "5"
            GetItemType = "geoFreeform"
        Case Is = "9"
            GetItemType = "geoLine"
        Case Is = "17"
            GetItemType = "geoTextBox"
        Case Else
            GetItemType = "Can Not Determine Type of Shape"
    End Select
    
    
    
    Exit Function
    error&#58;
    GetItemType = "Can Not Determine Type of Object"
    
    
    End Function

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. detecting mappoint in vba
    By OregonIzer in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 07-21-2005, 11:56 AM
  2. Retrieve the clicked country name
    By Abilio Serafim in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-27-2005, 06:10 AM
  3. Detecting the currently selected pushpin
    By daxydoggie in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 11-19-2003, 03:57 AM
  4. Return the state that is being clicked on
    By Tarren in forum MapPoint Desktop Discussion
    Replies: 8
    Last Post: 04-10-2003, 01:31 PM
  5. As I draw a line and then a pushpin on that line, ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-16-2002, 08:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83