Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: need info mappoint/gps/vb6 developement

  1. #21
    Join Date
    Apr 2004
    NL-Bergschenhoek (near Rotterdam)

    distanceto (what)

    "if your car is off the route, (your route is stored in a collection(...)) then re-calculate the route"

    How do you know if the car is of route? Do you use the distanceto prop.? That does, i think, only a calculation between 2 fixed points and not towards a line, aka the route which goes between two waypoints.
    For example, your route is over a major road for a long time where route starts at the begining and ends at the end of that same road. Given the fact that there are no waypoints inbetween.
    How do you detect if you drive at, for example, a parallel road.
    Cause i dont know how to calculate the distance from an actual gps position to the 'major road'/the route as mentioned above. I only know the props. distanceto and it calculates towards the nearest 'gridpoint' which is the nearest to the given location (and not even to the location itself!). The latter isn't important at long routes but there is a difference on short routes.

    I was thinking of adding one waypoint (called 'CP' from current position) to the route waypoints. Then calculate to know if you are off track (not sure how to do this exactly). If you're 3 times off track on a row and the distance is growing than it is supposed that you are leaving the original route. Recalc of the route should be nessecary. This 'three time calculation' is done to detect that it isn't the shift by the mappoint grid (the current position is matched to the mappoint grid) but it is you going really off track.

    On a static map i have done a test with the 'location sensor' from the tools menu.
    I wrote down the lat and lon figures for a position on a road.
    Then, in code, put a waypoint at that location.
    This waypoint was not placed on the same position! But on a invisible grid crossing, i believe.
    One time it placed me on a side road which wasn't reachable from the main road (only could be reached by driving through the neighbourhood). If i pointed a bit down the road and repeated the above, mappoint placed the waypoint at the same position. Only if I pointed far enough away the position changed to an other position on the road, but again much further as the pointed position. Again at the nearest invisible grid crossing i believe.

  2. #22
    Join Date
    Apr 2004
    NL-Bergschenhoek (near Rotterdam)

    Here it is!!!

    With many thanks to Gilles Kohl [MVP]

    Option Explicit
    Dim oMpApp As MapPoint.Application
    Dim WithEvents oMap As MapPoint.Map

    Private Sub Form_Load()
    ' Try to attach to running instance of MapPoint
    On Error Resume Next
    Set oMpApp = GetObject(, "MapPoint.Application")
    On Error GoTo 0

    If oMpApp Is Nothing Then
    ' Attaching failed - try creating an object
    On Error Resume Next
    Set oMpApp = CreateObject("MapPoint.Application")
    On Error GoTo 0

    If oMpApp Is Nothing Then
    MsgBox "Could not create MapPoint object"
    End If
    ' make the app visible
    oMpApp.Visible = True
    End If

    ' Ensure MapPoint survives when app terminates
    oMpApp.UserControl = True

    ' Retrieve the active map
    Set oMap = oMpApp.ActiveMap
    End Sub

    Private Sub oMap_MouseMove(ByVal Button As Long, ByVal Shift As Long,
    ByVal X As Long, ByVal Y As Long)
    If Not oMap.ActiveRoute.IsCalculated Then Exit Sub

    Dim oLoc As MapPoint.Location
    Set oLoc = oMap.XYToLocation(X, Y)
    ' For GPS use, change into Set oLoc = oMap.GetLocation(dblLat,
    dblLon, 0)
    Dim dblDist As Double
    dblDist = oMap.ActiveRoute.Directions.DistanceTo(oLoc)
    Text1.Text = Str(dblDist)
    If dblDist < 0.05 Then
    Text1.BackColor = vbGreen
    Text1.BackColor = vbRed
    End If
    End Sub

Page 3 of 3 FirstFirst 123

Similar Threads

  1. File Info / Movie Info
    By frodobaggins in forum FP FAQ
    Replies: 0
    Last Post: 12-01-2004, 05:42 PM
  2. MP3Car 200W psu info?
    By kefka_killer in forum Power Supplies
    Replies: 3
    Last Post: 07-20-2004, 02:45 AM
  3. LM64P89 LCD screen info ?
    By bobit in forum LCD/Display
    Replies: 2
    Last Post: 12-01-2002, 11:12 PM
  4. Any info on this laptop dvd drive
    By tapper1999 in forum General Hardware Discussion
    Replies: 3
    Last Post: 01-15-2002, 04:54 PM
  5. a database of id3 info
    By etrik in forum Software & Software Development
    Replies: 16
    Last Post: 01-18-2001, 11:45 AM


Posting Permissions

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