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

Mappoint and Access Driving time

This is a discussion on Mappoint and Access Driving time within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello all Thanks in advance Hello, I have an access database that is used for scheduling audits. What i would ...

  1. #1
    bigbore50 is offline Junior Member White Belt
    Join Date
    Jan 2007
    Posts
    3

    Mappoint and Access Driving time

    Hello all

    Thanks in advance

    Hello,
    I have an access database that is used for scheduling audits. What i would like to do is get the driving time from the auditors house to the location of the audit.

    I have a query returning available auditors and their address[qry_USEABLE_REPS_forSTATE]
    I also have a query returning the address for the PDN(primary dealer) that was selected [qry_dlr#-and-drive-time].

    What i want to do is calculate the driving time between the two locations

    Exp.
    When i run [qry_USEABLE_REPS_forSTATE] i will get this:
    Rep Address City State Zip
    rep1 247 dayton rd dawson pa 15428
    rep2 287 rough drive cranberry pa 16066
    rep3 124 juniper drive butler pa 16066

    When i run [qry_dlr#-and-drive-time] i will get.
    PDN Dealer Name Address city state zip
    12345 John howard 216 dear st erie pa 16507


    What i want to do is run a loop that looks at the first rep in [qry_useable_reps_forstate] and calculates driving distance to the dealer location in [qry_dlr#-and-drive-time]

    After it looks at the first rep it returns a drivetime for rep1
    then goes to rep2 and so on


    I want to return the results to the form so that i can see how long it takes each rep to get to the dealer


    Is this possible?

    thanks

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Mappoint and Access Driving time

    Hi,

    You have to look at FindPlaceResults or FindAddressResults method which returns Location objects for the addresses. Then you can add Waypoint objects to the Route object. Eventually set DriverProfile and other properties. After you call the Calculate method the drivingtime and other properties are calculated.

  3. #3
    bigbore50 is offline Junior Member White Belt
    Join Date
    Jan 2007
    Posts
    3

    Re: Mappoint and Access Driving time

    That is confusing. Do you have any examples of how the code should look?

    thanks

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Mappoint and Access Driving time

    Hi,

    Here is quick example in c#.

    Code:
        FindResults results = MP.ActiveMap.FindAddressResults(street, city, "", "", zip, "");
        if (results.ResultsQuality == GeoFindResultsQuality.geoFirstResultGood) {
    	Route route = MP.ActiveMap.ActiveRoute;
    	route.Clear();
    
    	// set first point
    	object o = 1;
    	Location loc = (Location)results.get_Item(ref o);
    	Waypoint wp = route.Waypoints.Add(loc, loc.Name);
    	wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;
    
    	results = MP.ActiveMap.FindAddressResults(street2, city2, "", "", zip2, "");
    	if (results.ResultsQuality == GeoFindResultsQuality.geoFirstResultGood) {
    	    // set last point
    	    o = 1;
    	    loc = (Location)results.get_Item(ref o);
    	    wp = route.Waypoints.Add(loc, loc.Name);
    	    wp.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;
    
    	    // set preferred roads
    	    route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadArterial, 0.1);
    	    route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadFerry, 0.1);
    	    route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadInterstate, 0.9);
    	    route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadOtherHighway, 0.6);
    	    route.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadToll, 0.2);
    
    	    // set preferred speeds
    	    route.DriverProfile.set_Speed(GeoRoadType.geoRoadArterial, 50);
    	    route.DriverProfile.set_Speed(GeoRoadType.geoRoadInterstate, 120);
    	    route.DriverProfile.set_Speed(GeoRoadType.geoRoadLimitedAccess, 120);
    	    route.DriverProfile.set_Speed(GeoRoadType.geoRoadOtherHighway, 90);
    	    route.DriverProfile.set_Speed(GeoRoadType.geoRoadStreet, 50);
    
    	    route.DriverProfile.StartTime = System.DateTime.Now;
    	    route.Calculate();
    
    	    Console.WriteLine("Minutes " + route.TripTime * 1440);

  5. #5
    bigbore50 is offline Junior Member White Belt
    Join Date
    Jan 2007
    Posts
    3

    Re: Mappoint and Access Driving time

    Ok I don't know why this is not working. It looks fine to me

    For now all i am trying to do is put the drive time into a text box

    Code:
    Private Sub Command2_Click()
        'Define variables to hold our information.
        Dim oApp As Object, omap As Object
        Dim oPush(1 To 2) As Object
        Dim oloc As Object
        Dim oLOCtwo As Object
        Set oApp = CreateObject("Mappoint.Application")
        Set omap = oApp.NewMap  'Create a new map
        
        Set oloc = omap.Find("247 davis road" & " , " & Dawson & " , " & PA & ", " & 15428) 'Geocode the first address
        If Not oloc Is Nothing Then      'Check to see if the first address was found.
            Set oPush(1) = omap.AddPushpin(oloc) 'Place a pushpin on the map
            oPush(1).GoTo               'Go to that pushpin
        
        Set oLOCtwo = omap.Find("1801 Trenton Ct" & " , " & "Cranberry Twp" & " , " & PA & " , " & 16066)  'Geocode the second address
            If Not oLOCtwo Is Nothing Then 'Check to see if the second address was found
            Set oPush(2) = omap.AddPushpin(oLOCtwo) 'Add a pushpin for it
            oPush(2).Highlight = True
            
                With omap.ActiveRoute       'Let's generate some directions between the points
                    omap.Waypoints.Add oloc  'Add the first address
                    omap.Waypoints.Add oLOCtwo  'Add the second address
                    omap.ActiveRoute.Calculate      'Now find the directions between them
                End With
                
    Me.Text0 = Console.WriteLine("Minutes " + omap.ActiveRoute.TripTime * 1440)
            Else                'If the second location is not found, then indicate no directions
                Me.Text0.SetFocus
                Me.Text0.text = "No second location found!"
            End If
                
        Set omap = Nothing
        Set oApp = Nothing
        End If
    End Sub

    Any ideas
    Last edited by Wilfried; 01-29-2007 at 03:40 PM.

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Mappoint and Access Driving time

    Hi,

    I have edit your post and put the code into [ code ] tags. Please do so in future because to make it more readable.

    Please tell me (before I further investigate) what exacly is *not* working ?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Driving Directions
    By garon5 in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-25-2006, 10:07 AM
  2. Driving time between each waypoint
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-10-2005, 06:42 AM
  3. driving directions
    By impala454 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-11-2004, 10:49 AM
  4. Set average driving speed in Mappoint WebService
    By Anonymous in forum Bing Maps and MapPoint Web Service
    Replies: 1
    Last Post: 06-01-2004, 07:57 AM
  5. Driving Day - How to turn off?
    By Clive2004 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-06-2004, 06:42 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