someone could give me a simple sample how could i implement the follow situation using GMLib: I have some address(street, number, city) e i would like to make a route using the google maps connecting all of them. I am using Delphi XE2. Thanks very much!
You need a TWebBrowser, a TGMMap and a TGMDirection and connect the components so:
TGMDirection.Map -> TGMMap TGMMap.WebBrowser -> TWebBrowser
Active TGMMap (Active := true) and on AfterPageLoaded event put this code:
procedure TMainFrm.GMMap1AfterPageLoaded(Sender: TObject; First: Boolean);
begin
if First then GMMap1.DoMap;
end;
Now, you only need to configure your TGMDirection with Origin and Destination address and call Execute method:
// minimum config
TGMDirection.DirectionsRequest.Origin.Address := 'Origin address';
TGMDirection.DirectionsRequest.Destination.Address := 'Destination address';
TGMDirection.Execute;
You need to know that all call to Execute method create a new Item into DirectionsResult array. This array have Count items (0 based). Also you need to know that each result can return (if Status = dsOK) 1 or more results stored into Routes array (0 based too).
TGMDirection.DirectionsResult -> array with all request
TGMDirection.DirectionsResult[X].Routes -> array with all results of a request if Status = dsOK
Regards