Hello,
I am currently converting a project from the TMS VCL WebGMaps to the TMS FNC Maps. I have to change the MapLabel to the OverlayView for many markers.
Unfortunately, the overlay view is not displayed when I create it directly with all my other markers and polylines during the opening of map form. Only when I create another marker via a button is the overlay text displayed for all markers.
Reduced to a short test project:
(Form1 ...) (uses Unit 2)
procedure TForm1.BitBtn1Click(Sender: TObject);
var
Frm: TForm2;
begin
Frm := TForm2.Create(self);
Frm.ShowModal;
Frm.Release;
end;
(From2 ... contains a TMSFNCGoogleMaps1: TTMSFNCGoogleMaps;)
procedure TForm2.FormCreate(Sender: TObject);
begin
FFirstShow := true;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
if FFirstShow = true then
begin
InitMap(Sender);
FFirstShow := false;
end;
end;
procedure TForm2.InitMap(Sender: TObject);
var MarkerCentre: TTMSFNCGoogleMapsMarker;
begin
TMSFNCGoogleMaps1.BeginUpdate;
MarkerCentre := TMSFNCGoogleMaps1.Markers.Add;
MarkerCentre.Latitude := TMSFNCGoogleMaps1.Options.DefaultLatitude;
MarkerCentre.Longitude := TMSFNCGoogleMaps1.Options.DefaultLongitude;
MarkerCentre.AddOverlayView('Test Overlay Text');
TMSFNCGoogleMaps1.EndUpdate;
end;
When the InitMap has run through, only the marker is displayed, but no overlay view (with the Text 'Test Overlay Text').
When the Btn1 in From2 is pressed, the second marker and the overlays for both markers ('Test Overlay Text' AND 'Test Overlay Text 2') appear on the map.
procedure TForm2.BitBtn1Click(Sender: TObject);
var MarkerCentre: TTMSFNCGoogleMapsMarker;
begin
TMSFNCGoogleMaps1.BeginUpdate;
MarkerCentre := TMSFNCGoogleMaps1.Markers.Add;
MarkerCentre.Latitude := TMSFNCGoogleMaps1.Options.DefaultLatitude + 0.01;
MarkerCentre.Longitude := TMSFNCGoogleMaps1.Options.DefaultLongitude + 0.01;
MarkerCentre.AddOverlayView('Test Overlay Text 2');
TMSFNCGoogleMaps1.EndUpdate;
end;
How do I have to proceed correctly? Do I have to wait for an event before creating the markers and overlayViews or something like that?