Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS FMX WebGMaps
How to redraw all the markers

There are two possible techniques:
  1. Clear all markers from the Markers collection and add the markers again so they also show on the map.
  2. Iterate the Markers collection and call CreateMapMarker for each Marker to show it on the map.
Please note that it is required to wait until after the OnMapTilesLoad event has been triggered to add the markers.

Example 1:

procedure TForm2.Button1Click(Sender: TObject); begin
  TMSFMXWebGMaps1.Visible := not TMSFMXWebGMaps1.Visible;

  if TMSFMXWebGMaps1.Visible then
    MapIsVisible := true;
end;

procedure TForm2.FormCreate(Sender: TObject); begin
  InitMarkers;
end;

procedure TForm2.InitMarkers;
begin
  TMSFMXWebGMaps1.Markers.Clear;
  TMSFMXWebGMaps1.Markers.Add(48.8, 2);
  TMSFMXWebGMaps1.Markers.Add(48.7, 2);
end;

procedure TForm2.TMSFMXWebGMaps1MapTilesLoad(Sender: TObject); var
  I: Integer;
begin
  if MapIsVisible then
  begin
    MapIsVisible := false;
    InitMarkers;
  end;
end;
Example 2:

procedure TForm2.Button1Click(Sender: TObject); begin
  TMSFMXWebGMaps1.Visible := not TMSFMXWebGMaps1.Visible;

  if TMSFMXWebGMaps1.Visible then
    MapIsVisible := true;
end;

procedure TForm2.FormCreate(Sender: TObject); begin
  InitMarkers;
end;

procedure TForm2.InitMarkers;
begin
  TMSFMXWebGMaps1.Markers.Clear;
  TMSFMXWebGMaps1.Markers.Add(48.8, 2);
  TMSFMXWebGMaps1.Markers.Add(48.7, 2);
end;

procedure TForm2.TMSFMXWebGMaps1MapTilesLoad(Sender: TObject); var
  I: Integer;
begin
  if MapIsVisible then
  begin
    MapIsVisible := false;
    for I := 0 to TMSFMXWebGMaps1.Markers.Count - 1 do
      TMSFMXWebGMaps1.CreateMapMarker(TMSFMXWebGMaps1.Markers[I]);
  end;
end;