【问题标题】:Exception when calling GMLIB.SetCenter调用 GMLIB.SetCenter 时出现异常
【发布时间】:2018-07-10 09:16:55
【问题描述】:

在我的主表单上,我有一个客户列表。我可以选择一个客户,然后单击一个按钮,加载 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 的中心以显示新的客户位置。

德尔福 XE

GMLIB 1.5.5

【问题讨论】:

  • AfterPageLoaded 事件处理程序中做你的事情。
  • @Victoria 谢谢。我曾尝试将内容移至该事件,但出现脚本错误。不过我会再试一次。
  • 更新 requiredProp.center 并在 AfterPageLoaded 事件中调用 gmMap.setCenter 会显示“发生脚本错误”消息(代码 80020101)。我什至尝试将 gmMap 的所有其他事件设置为 nil,然后在 AfterPageLoadedevent 完成后重新分配它们,但我得到了相同的脚本错误。

标签: delphi gmlib


【解决方案1】:

我找到了解决办法。

我根本不需要调用 setCenter。我只需要设置RequiredProps.Center.Lat 和Lng 就可以了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-06
    • 2017-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多