MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Get Distance Help

This is a discussion on Get Distance Help within the Development forums, part of the MapPoint 2006/2009 Discussion category; I need to calculate the driving distance between 2 addresses. I was wondering if anyone had a sample of VBA ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion > Development

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (2) Thread Tools Display Modes
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-26-2008
Junior Member
Yellow Belt
 
Join Date: Jun 2006
Posts: 16
Get Distance Help

I need to calculate the driving distance between 2 addresses. I was wondering if anyone had a sample of VBA code I could use within Access. I have 2 addresses in a record. The user clicks a "Map It" command button and the map with route is displayed. I used this code from the sample MDB file ChrisG posted and it works great. I assume I would just add a "get distance" statement but that's just a guess on my part.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 11-26-2008
Auge_Ohr's Avatar
Member
Green Belt
 
Join Date: Sep 2008
Location: Hamburg, Germany
Posts: 60
Re: Get Distance Help

hi,
Quote:
Originally Posted by plevine1 View Post
I need to calculate the driving distance between 2 addresses. I was wondering if anyone had a sample of VBA code I could use within Access. I have 2 addresses in a record. The user clicks a "Map It" command button and the map with route is displayed. I used this code from the sample MDB file ChrisG posted and it works great. I assume I would just add a "get distance" statement but that's just a guess on my part.
while you did not post some Code i can not Qoute it.

after the :Calculate() Methode add a new Line with :Distance()
Code:
Xbase++ Syntax
::oAXControl:ActiveMap:ActiveRoute:Distance()
__________________
greetings by OHR
Jimmy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 11-26-2008
Junior Member
Yellow Belt
 
Join Date: Jun 2006
Posts: 16
Re: Get Distance Help

Sorry, here is the code I used. My real goal is to store the distance and travel time to field1 and field2.

Private Sub cmdMap_Click()
Dim oApp As Object, oMap As Object, oPush(1 To 2) As Object, oLoc(1 To 2) As Object

Set oApp = CreateObject("Mappoint.Application")
Set oMap = oApp.NewMap

Set oLoc(1) = oMap.Find(Address & " , " & City & " , " & State)
Set oLoc(2) = oMap.Find(Address2 & " , " & City2 & " , " & State2)
If Not oLoc(1) Is Nothing Then
Set oPush(1) = oMap.AddPushpin(oLoc(1))
oPush(1).GoTo

If Not IsNull(MyName) Then oPush(1).Name = MyName
oPush(1).Highlight = True

If Not oLoc(2) Is Nothing Then
Set oPush(2) = oMap.AddPushpin(oLoc(2))

oPush(2).Highlight = True

With oMap.ActiveRoute
.Waypoints.Add oLoc(1)
.Waypoints.Add oLoc(2)
.Calculate
End With
oMap.CopyDirections
txtDir.SetFocus
RunCommand acCmdPaste

Else
txtDir.SetFocus
txtDir.Text = "No second location found!"
End If

oMap.DataSets(1).ZoomTo
oMap.CopyMap
imgClip.Visible = True
imgClip.Action = acOLEPaste

lblMapInfo.Caption = ""

Else
lblMapInfo.Caption = "Address Not Found!"
End If
Set oMap = Nothing
Set oApp = Nothing
Me.SetFocus


End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 11-26-2008
Auge_Ohr's Avatar
Member
Green Belt
 
Join Date: Sep 2008
Location: Hamburg, Germany
Posts: 60
Re: Get Distance Help

hi,
Quote:
Originally Posted by plevine1 View Post
My real goal is to store the distance and travel time to field1 and field2.
Code:
With oMap.ActiveRoute
       .Waypoints.Add oLoc(1)
       .Waypoints.Add oLoc(2)
       .Calculate
End With
oMap.CopyDirections
txtDir.SetFocus
RunCommand acCmdPaste
as i say, just after .Calculate add a new Line with .Distance()

Travel Time depends on your Drive Profile e.g. Speed.
use TripTime property (Route) to get Travel Time.
__________________
greetings by OHR
Jimmy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
distance


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/get-distance-help-9171.html

Posted By For Type Date
MapPoint Download - MP2K Magazine This thread Refback 12-02-2008 12:29 AM
Formatting coordinates with DmsFormat, linking to weather data, three new utilities - MP2K Update Archives - MP2K Magazine This thread Refback 11-28-2008 10:22 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Minimum Distance JDells MapPoint Web Service and Virtual Earth 0 06-05-2007 03:12 PM
mappoint distance cptkirkh MapPoint 2006/2009 Discussion 1 01-31-2007 01:24 PM
distance Anonymous MapPoint 2006/2009 Discussion 0 02-11-2004 01:03 PM
Distance from Polygon random0000 MapPoint 2006/2009 Discussion 1 04-14-2003 10:18 PM
distance Anonymous MapPoint 2006/2009 Discussion 1 11-22-2002 03:09 PM


All times are GMT -5. The time now is 07:02 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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