我使用 TGMDirection 来显示我点击的两个标记之间的路线。与这里的想法相同,但在 Delphi 中使用 GMLib 1.8: http ://www.geocodezip.com/inventoresdegaragem_com_dbteste_indexB.html
第一方向 它显示没有任何错误。当我再次单击另一个标记时,它会弹出并脚本错误:行:539 个字符:9 错误:无法检索属性关闭的值:对象为空或未定义代码:0 URL:关于:空白
你有什么主意吗 ?我使用的代码是:
procedure TForm1.GMMarker1DblClick(Sender: TObject; LatLng: TLatLng;
Index: Integer; LinkedComponent: TLinkedComponent);
begin
if legcount = 0 then
begin
marker1index :=Index;
legcount:=legcount+1;
end
else if legcount = 1 then
begin
legcount:=0;
marker2index :=Index;
GMDirection1.DirectionsRequest.Origin.LatLng := GMMarker1.Items[marker1index].Position;
GMDirection1.DirectionsRequest.Destination.LatLng := GMMarker1.Items[marker2index].Position;
GMDirection1.Execute;
if GMDirection1.DirectionsResult[routenr].Status = dsOK then
begin
GMDirection1.Free;
end;
routenr:=routenr+1;
end;
end;