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
This is a discussion on add two waypoints and calculate route with Delphi within the MapPoint Desktop Discussion forums, part of the Map Forums category; I would like some sample code in Delphi to Add two route waypoints and calculate the route. I have seen ...
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
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;
Thank you for the reply. Using Lat and Long. works perfectly. Do you have an example using street addresses?
Jim
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
Rainer: I have the route working. Thanks to your help, I had the information I needed to do the rest of it.
Regards,
Jim
There are currently 1 users browsing this thread. (0 members and 1 guests)