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

How to continuosly add a GPS pushpin on MP2006?

This is a discussion on How to continuosly add a GPS pushpin on MP2006? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi everyone: I have to say Thank you!!!! for the wealth of information everyone on this post is sharing about ...

  1. #1
    joseph975 is offline Junior Member White Belt
    Join Date
    Oct 2007
    Posts
    3

    Question How to continuosly add a GPS pushpin on MP2006?

    Hi everyone: I have to say Thank you!!!! for the wealth of information everyone on this post is sharing about mappoint. Information which for the most part, is not found anywhere else.

    I am using vb6 and mp2006, and I am also new to programming. ---- Problem: I do not know how to continually display the lat/lot information coming from my GPS. I have two "Public" variables one for latitude (lat) and another one for longitude (lot) which are constantly receiving the already parsed lat/lot coordinates from the GPS, but the GetLocation method allows me to place only one pushpin on on the map. (See the last procedure below) What code do I use to place one pushpin every 1 or 2 seconds on the map based on the lat/lot info from the GPS?

    code below:

    --------------------------------------------------------------------------

    Public lat As Double
    Public lon As Double

    Private Sub Form_Load()
    Dim objMap As MapPointCtl.map
    Set objMap = MappointControl1.NewMap(geoMapNorthAmerica)
    Set objMap = MappointControl1.ActiveMap
    call position_gps
    End Sub

    Private Sub form_unload(cancel As Integer)
    MappointControl1.ActiveMap.Saved = True
    End Sub

    Private Sub position_gps()
    Dim mymap As MapPointCtl.map
    Dim myLoc As MapPointCtl.Location
    Dim mypushpin As MapPointCtl.Pushpin
    Set mymap = MappointControl1.ActiveMap
    Set myLoc = mymap.GetLocation(lat, lon)
    Set mypushpin = mymap.AddPushpin(myLoc)
    mypushpin.Symbol = 83
    mypushpin.Location.GoTo

    End Sub

    --------------------------------------------------------------------------

    There is one or two similar threads, but no code is posted on the solution to this question.

  2. #2
    Mattys Consulting's Avatar
    Mattys Consulting is offline Senior Member Black Belt
    Join Date
    Dec 2002
    Posts
    1,040

    Re: How to continuosly add a GPS pushpin on MP2006?

    Hi Joseph,

    If you're trying to create a trail, "every one or two seconds" isn't even useful.
    Besides, the refreshing of the screen will be continuous - you see no changes
    until the screen is 'at rest.'

    If you're only trying to track a vehicle, declare a variable as PushPin
    and then change the location of the pin instead of adding new ones.

    Mike Mattys

  3. #3
    joseph975 is offline Junior Member White Belt
    Join Date
    Oct 2007
    Posts
    3

    Re: How to continuosly add a GPS pushpin on MP2006?

    Thank you for your reply!

    The code I have adds one pushpin to the map. How do I change/update the coordinates to a pin already on the map?

    Joseph

  4. #4
    Mattys Consulting's Avatar
    Mattys Consulting is offline Senior Member Black Belt
    Join Date
    Dec 2002
    Posts
    1,040

    Re: How to continuosly add a GPS pushpin on MP2006?

    Hi Joseph,

    Sorry, workday ...

    I believe I'd just do this:

    [Aircode]
    Set myLoc = mymap.GetLocation(lat, lon)
    Set mypushpin.location = myLoc.location

    Mike Mattys

  5. #5
    joseph975 is offline Junior Member White Belt
    Join Date
    Oct 2007
    Posts
    3

    Re: How to continuosly add a GPS pushpin on MP2006?

    Mike:

    The code is still not compiling properly, I am getting a "variable not set" error. The object.location property seems to be the way to do it, but something I am doing is obviously wrong.

    Just like you suggested, the "Programming Mappoint in .NET" book has a section which describes this process in C# , and although the code is different to VB6 the steps are similar:

    currPushpin.Location = myloc; (in C#)

    This is where the pushpin is supposed to keep updating its location from the myloc variable.

    If I use the code you suggested:

    Set myLoc = mymap.GetLocation(lat, lon)
    Set mypushpin.location = myLoc.location

    without adding the pushpin first with ...AddPushpin(myloc) I get a "variable not set" error.

    If I use the following code:

    Set myLoc = mymap.GetLocation(lat, lon)
    Set mypushpin = mymap.AddPushpin(myLoc)
    Set mypushpin.location = myLoc.location

    I do not think it is correct to set a variable twice like that; therefore, the code does not produce the desired outcome. It just adds the pin, but no update.

    Thank you again for your time and ideas. If you can think of any other way to fix this problem, any other suggestion is always welcome.

    Joseph.

  6. #6
    Mattys Consulting's Avatar
    Mattys Consulting is offline Senior Member Black Belt
    Join Date
    Dec 2002
    Posts
    1,040

    Re: How to continuosly add a GPS pushpin on MP2006?

    Let's say you have a menu item by the name of mnuExample
    This will demonstrate how to continuously move your pushpin.

    Private Sub mnuExample_Click(Index As Integer)
    Dim MyMap As MapPoint.Map
    Dim MyPin As MapPoint.Pushpin
    Dim MyLoc As MapPoint.Location
    Dim iloc As Long
    Dim dlat As Double, dlon As Double

    dlat = 43.223
    dlon = -77.573
    Set MyMap = MapCtl.Object.ActiveMap
    Set MyLoc = MyMap.GetLocation(dlat, dlon, 1)
    Set MyPin = MyMap.AddPushpin(MyLoc)
    MyPin.Location.GoTo

    For iloc = 0 To 200
    Set MyPin.Location = MyMap.GetLocation(dlat, dlon, 1)
    dlat = dlat + iloc / 1000
    dlon = dlon + iloc / 1000
    Set MyLoc = MyMap.GetLocation(dlat, dlon, 1)
    MyPin.Location.GoTo
    Next

    Set MyLoc = Nothing
    Set MyMap = Nothing
    End Sub

    Mike Mattys

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to continually display GPS pushpin on MP2006??
    By mares123 in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-20-2007, 02:29 PM
  2. can i use mp2006 locally
    By salmap in forum Development
    Replies: 2
    Last Post: 10-16-2007, 03:12 PM
  3. MP2006 - C# - Very SLOW closing map
    By pcfountain in forum Development
    Replies: 1
    Last Post: 05-22-2007, 12:44 PM
  4. Add-in / MP2006 Memory Clash?
    By Winwaed in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-27-2006, 06:00 PM
  5. MP2006 backward compatibility
    By Wilfried in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-08-2006, 04:10 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