Community of VE/MapPoint Users and Developers
This is a discussion on Mappoint and Access Driving time within the MapPoint 2006/2009 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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Mappoint and Access Driving time 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 |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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);
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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. |
| |||
| 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 ?
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| access, driving, mappoint, time |
| ||||
| Posted By | For | Type | Date | |
| Using MapPoint from Word, Access and Excel - MapPoint Articles - MP2K Magazine | This thread | Refback | 01-24-2007 01:01 PM | |
| Companies - MP2K Magazine | This thread | Refback | 01-23-2007 05:30 PM | |
| MapPoint Help - MP2K Magazine | This thread | Refback | 01-23-2007 11:26 AM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Driving Directions | garon5 | MapPoint 2006/2009 Discussion | 0 | 12-25-2006 10:07 AM |
| Driving time between each waypoint | Anonymous | MapPoint 2006/2009 Discussion | 1 | 05-10-2005 06:42 AM |
| driving directions | impala454 | MapPoint 2006/2009 Discussion | 1 | 12-11-2004 10:49 AM |
| Set average driving speed in Mappoint WebService | Anonymous | MapPoint Web Service and Virtual Earth | 1 | 06-01-2004 07:57 AM |
| Driving Day - How to turn off? | Clive2004 | MapPoint 2006/2009 Discussion | 1 | 01-06-2004 06:42 AM |