有人可以给我一个简单的例子,我如何使用GMLib实现以下情况:我有一些地址(街道,数字,城市)e我想制定一条路线使用谷歌地图连接所有这些。我使用的是Delphi XE2。非常感谢!
发布于 2013-05-06 17:33:57
您需要一个TWebBrowser、一个TGMMap和一个TGMDirection,并将这些组件连接起来,以便:
TGMDirection.Map -> TGMMap TGMMap.WebBrowser -> TWebBrowser
Active TGMMap (Active := true)和on AfterPageLoaded事件放入此代码:
procedure TMainFrm.GMMap1AfterPageLoaded(Sender: TObject; First: Boolean);
begin
if First then GMMap1.DoMap;
end;现在,您只需要为您的TGMDirection配置源地址和目的地址,并调用Execute方法:
// minimum config
TGMDirection.DirectionsRequest.Origin.Address := 'Origin address';
TGMDirection.DirectionsRequest.Destination.Address := 'Destination address';
TGMDirection.Execute;您需要知道所有对Execute方法调用都会在DirectionsResult数组中创建一个新项。此数组具有计数项(以0为基数)。此外,您还需要知道每个结果可以返回(如果Status = dsOK) 1个或更多存储到路由数组中的结果(也以0为基数)。
TGMDirection.DirectionsResult -> array with all request
TGMDirection.DirectionsResult[X].Routes -> array with all results of a request if Status = dsOK问候
https://stackoverflow.com/questions/16389853
复制相似问题