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 8 of 8

Long/Lat from click.

This is a discussion on Long/Lat from click. within the MapPoint Desktop Discussion forums, part of the Map Forums category; I am working on a tracking system and mappoint is my mapping software. I am using VB for my programming. ...

  1. #1
    Milo is offline Junior Member White Belt
    Join Date
    Oct 2004
    Posts
    10

    Long/Lat from click.

    I am working on a tracking system and mappoint is my mapping software. I am using VB for my programming. At the moment i am doing geofencing and what i want to do is be able to get the lats and longs of a location where i click on the map...is this possible? thanks
    =========
    Milo

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478

  3. #3
    EdB
    EdB is offline Member Green Belt
    Join Date
    Aug 2002
    Posts
    56
    You know, I don't think that's the answer he's looking for, though I could be wrong. If I'm not, I'm looking for the same answer.

    The article points to a routine that is well known around here for extracting the lat/long from a pushpin. But what if you are just trying to react to a users click of a spot on the map, similar to what the location tool does.....as you move about on the map it reports the lat/long.

    The closest thing I can get to that involves the user having to place a pushpin at the desired location, then push a VB button.....which then executes the above.......as long as the user doesn't change the name of the pushpin.

  4. #4
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Look at the MouseDown or MouseUp event

    X ByVal Long. The X coordinate of the mouse pointer relative to the map window, in pixels.
    Y ByVal Long. The Y coordinate of the mouse pointer relative to the map window, in pixels
    In that event you will get the x/y of the mouse.

    Now take a look at the XYToLocation method. Use it to take the x/y of the mouse and get a location object. At this point you should have the required stuff to use the calcpos function to return the lat/lon.

    Also, there is another article that uses the same concept in .net to demonstrate the location sensor (uses the mousemove event)
    http://www.mp2kmag.com/a66--location....mappoint.html

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Where have you been all my life?


  6. #6
    Milo is offline Junior Member White Belt
    Join Date
    Oct 2004
    Posts
    10
    yeah this is what i have come to but i dont know how yo use the function calcpos. could you give an exapmle of how to use it? I keep getting an error, object variable or with block variable not set.

    Regards,
    =========
    Milo

  7. #7
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Ok, Let me know if this works for you.

    Visual Basic 6
    Assumes you have the CalcPos Sub and the Function Arccos by Author Gilles Kohl in you project. http://www.mp2kmag.com/articles.asp?ArticleID=13
    References: Microsoft MapPoint 11.0 Object Library(North America)
    MapPointControl.ocx is on Form1
    One Command Button (Command1)


    Code:
    Public ilat As Double
    Public ilon As Double
    
    Private Sub Form_Load()
    Dim objmap As MapPointctl.Map
    Set objmap = MappointControl1.NewMap(geoMapNorthAmerica)
    End Sub
    
    
    Private Sub Command1_Click()
    Dim objmap As MapPointctl.Map
    Set objmap = MappointControl1.ActiveMap
    Dim objLoc As MapPointctl.Location
    Dim objPushpin As MapPointctl.Pushpin
    Set objLoc = objmap.FindResults("Seattle, WA")(1)
    Set objPushpin = objmap.AddPushpin(objLoc, "My Test Pushpin")
    CalcPos objmap, objPushpin.Location, ilat, ilon
    MsgBox ilat & ", " & ilon
    End Sub

  8. #8
    Milo is offline Junior Member White Belt
    Join Date
    Oct 2004
    Posts
    10
    excellent!! the only problem is, is sometimes i'm getting "The parameter is incorrect" Does this work all over the world?
    =========
    Milo

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Where did I click on that line?
    By Jumbly in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 12-08-2004, 03:53 AM
  2. How to add click event for VB.Net ?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 12-31-2003, 12:15 AM
  3. Double Click on map
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 08-08-2003, 06:42 PM
  4. Mouse Click on legend
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-10-2003, 05:39 PM
  5. What happens when YOU click on a street?
    By schuchhardp in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 01-03-2003, 10:37 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 84 85 86 87 88 89 90 91 92 93 94 95 96