Results 1 to 7 of 7

Thread: Question about MapPoint and Current Vehicle Location

  1. #1
    Newbie
    Join Date
    Jan 2007
    Posts
    26

    Question about MapPoint and Current Vehicle Location

    I am developing my own FE in VB.net using MS MapPoint 2006. Currently, I have an NMEA interpreter that reads from the GPS and displays the Lat/Lon on the screen. I also found a way to add a "pushpin" for the vehicles current location. But I think that there might be a better way to display the vehicle location on the map. I have searched google and these forums to no avail...

    Here is the code that I have to show the vehicle location:

    Code:
            
            'set map starting point 
            objLoc = objMap.GetLocation(Lat, Lon)
    
            Dim objVehicle As MapPoint.Pushpin
    
    
            objVehicle = objMap.AddPushpin(objLoc, "")
    
            ' Change pushpin symbol (the one we added for this purpose) 
            objVehicle.Symbol = 336
            objLoc.GoTo()
    Currently this code works and I pass the Lat/Lon variables from the serial read function. But it appears when I turn on the MP balloons that it is really creating one pushpin ontop of another. Everytime the GPS updates I get a new balloon.

    Am I locating the vehicle properly? Any help is greatly appreciated.

    Thanks,

    Axel

  2. #2
    Low Bitrate RickS's Avatar
    Join Date
    Nov 2005
    Location
    Bethesda, MD
    Posts
    86
    On every data received event (every time you get new GPS data), you have to delete the old pushpin then create a new one. Move your declaration of objVehicle out of this subroutine so that it's global to the form (so it doesn't get re-declared every time the subroutine runs). and in it's place add objVehicle.delete() to this subroutine. You also need to do a bit of error checking in case objVehicle hasn't been defined/assigned yet...something like this:

    If Not objVehicle is nothing then
    objVehicle.delete()
    End If

  3. #3
    Newbie
    Join Date
    Jan 2007
    Posts
    26
    ahhh.... So I had the right idea just wrong implimentation. I changed my code and it appears that it is working.

    You would think that there would be an actuall vehicle location module built into mappoint directly... Oh well...

    Thanks,

    Axel

  4. #4
    Newbie
    Join Date
    Jan 2007
    Posts
    26
    I have MapPoint building routes but I am a little confused on the directions part. Do I need to rebuild the route everytime the GPS updates the current vehicle location? Or is there a simple way that mappoint knows where the vehicle located?

    Thanks,

    Axel

  5. #5
    Low Bitrate RickS's Avatar
    Join Date
    Nov 2005
    Location
    Bethesda, MD
    Posts
    86
    You've found one of the main problems with trying to build a car based, real-time GPS application with MP. MP cannot internally tell you if a location or pushpin is located on a route...you have to do it through educated guessing and error checking to see if your guess was correct.

    The following will tell you how much straight line distance is left from your current location (based on CurrentLatitude and CurrentLongitude) to an item in your directions collection (the route). When the distance gets to be less than some threshold you determine (I set it at <0.015), you can increment to the next item in the directions collection and most of the time it'll work.

    DistanceToNextAction = objRoute.Directions.Item(CurrentInstructionNumber) .DistanceTo(objMap.GetLocation(CurrentLatitude, CurrentLongitude))
    If DistancetoNextAction < 0.015 Then
    CurrentInstructionNumber += 1
    End If

    Sometimes it won't work which is where you have to setup some error checking to see if the distance gets progressively greater from your next direction item (that usually indicates you've got something wrong).

    Another thing I started working on, but haven't had a chance to finalize though it should work pretty well, is to get the name of the street you are currently on and iterate through the direction items to get a match. That'll tell you which direction item you are on then you can use the technique above to change to the next direction when you get to the "turn"

  6. #6
    Newbie
    Join Date
    Jan 2007
    Posts
    26
    So basically I am on the right track as far as real time GPS tracking. What it appears is that MP has no internal support for GPS tracking and basically when the GPS updates the LAT and LON I have to rebuild the route using my current location pushpin. And then determine if I am even on the road and run some error checking to make sure.

    Whew.... That was a tounge twister.

    Is there a GPS emulator that can be used to test this with? That would be alot easier than lugging the laptop to the truck and then trying it...

    Thanks for the info...

    -Axel

  7. #7
    Low Bitrate RickS's Avatar
    Join Date
    Nov 2005
    Location
    Bethesda, MD
    Posts
    86
    There is a GPS emulator available but I haven't used it so I can't remember what it's called...checkout the GPS section and/or coders corner...or do some Google searching.

    Check these out, looks like some REALLY useful information for what you (and I) are working on...

    http://www.mp2kmag.com/a137--gps.api.2006.mappoint.html

    http://www.mp2kmag.com/a139--point.i....mappoint.html

Similar Threads

  1. RR 3-30-05 ... Mappoint ...
    By guino in forum Road Runner
    Replies: 122
    Last Post: 04-06-2005, 12:47 AM

Bookmarks

Posting Permissions

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