Reputation: 549
On my main form, I have a list of customers. I can select a customer and then click a button that loads a GMMap and displays some information about that customer and shows the customers location.
This works great the first time it is called but produces an exception on subsequent calls. In the FormShow of the map form is the following ...
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;
When I call either gmMap.SetCenter or gmMap.PanTo for the second time I get an exception ...
Página inicial aun no cargada (Initial page not yet loaded)
However, moving the setCenter call to 'AfterPageLoaded' event produces a further exception (An error has occured in a script on this page).
My question is. How can I correctly reset a GMMap's center to display a new customer location each time I call my map form, from my main form.
Delphi XE
GMLIB 1.5.5
Upvotes: 0
Views: 81
Reputation: 549
I found the solution.
I do not need to call setCenter at all. I just need to set the RequiredProps.Center.Lat and Lng and that is it.
Upvotes: 0