add two waypoints and calculate route with Delphi

jmiller55
06-21-2003, 10:07 PM
I would like some sample code in Delphi to Add two route waypoints and calculate the route. I have seen a couple of samples but can't get it to work. Please post the complete procedure including the Var section, I am new to MapPoint.
Jim

rbarthels
06-23-2003, 07:04 AM
Perhaps this helps:

procedure CalculateDistance(dblLonFrom:double; dblLatFrom:double; dblLonTo:double; dblLatTo:double;var KM:double; var ZEIT:double);
var
aFromLocation:Location;
aToLocation:Location;
aRoute: Route;
begin
if (MPApplication=NIL) then
exit;

aFromLocation:=MPApplication.ActiveMap.GetLocation (dblLatFrom, dblLonFrom, 0.0);
aToLocation:=MPApplication.ActiveMap.GetLocation(d blLatTo, dblLonTo, 0.0);

Screen.Cursor := crHourGlass;

aRoute:=MPApplication.ActiveMap.ActiveRoute;
aRoute.Clear;
aRoute.Waypoints.Add(aFromLocation,'S');
aRoute.Waypoints.Add(aToLocation,'E');

aRoute.Calculate;

KM:=aRoute.Distance;
Zeit:=aRoute.DrivingTime;

Screen.Cursor := crDefault;
end;

jmiller55
06-23-2003, 02:15 PM
Thank you for the reply. Using Lat and Long. works perfectly. Do you have an example using street addresses?
Jim

rbarthels
06-24-2003, 06:54 AM
I wrote my own geocoding routines by using FindAddress, because I found the results of FindAddress sometimes very bad. You can download the program for geocoding from MP-magazine.

Then I put the coordinates in my database and make distance calculations this way.

So I didn't have a simple example.

Rainer

jmiller55
06-24-2003, 02:08 PM
Rainer: I have the route working. Thanks to your help, I had the information I needed to do the rest of it.
Regards,
Jim

 
Web mp2kmag.com
mapforums.com