在我的主窗体上,我有一个客户列表。我可以选择一个客户,然后单击一个按钮,该按钮加载一个GMMap,并显示有关该客户的一些信息和客户的位置。
这在第一次调用时效果很好,但在随后的调用中会产生一个异常。在地图表单的FormShow中如下所示...
procedure TfrmMap.FormShow(Sender: TObject);
begin
if not gmMap.Active then
begin
gmMap.Active := true;
end;
gmMap.RequiredProp.Center.Lat := customer.Lat;
gmMap.RequiredProp.Center.Lng := customer.Lng;
//Either of the following cause the exception after the first call success
gmMap.PanTo(gmMap.RequiredProp.Center.Lat, gmMap.RequiredProp.Center.Lng);
gmMap.SetCenter(gmMap.RequiredProp.Center.Lat, gmMap.RequiredProp.Center.Lng);
end;
procedure TfrmMap.FormClose(Sender: TObject; var Action: TCloseAction);
begin
gmMap.Active := false;
end;当我第二次调用gmMap.SetCenter或gmMap.PanTo时,我得到了一个异常...
Página inicial aun no cargada (Initial page not yet loaded)但是,将setCenter调用移动到'AfterPageLoaded‘事件会产生进一步的异常(此页上的脚本中发生错误)。
我的问题是。如何正确地重置GMMap的中心,以便在每次从主窗体调用地图窗体时显示新的客户位置。
Delphi XE
GMLIB 1.5.5
发布于 2018-07-11 19:28:30
我找到了解决方案。
我根本不需要调用setCenter。我只需要设置RequiredProps.Center.Lat和Lng,仅此而已。
https://stackoverflow.com/questions/51261459
复制相似问题