TMSFNCGoogleMaps Marker are drawn several times

I create around 8000 markers.
After "EndUpdate", all markers are drawn individually but than this is repeated one or more times.

Please specify the map service you are using as each service might have a different behavior. If possible, switch between mapping services and see if there is a difference.

As the service provider updates and refreshes sometimes, you might not be able to prevent this from happening.

As a suggestion, in case you use Google, please have a look at Google Maps clustering. It might resolve your issue. The topic is covered in detail in the documentation and also in my book with a detailed example using a database with hundreds of records.

Something else coming to mind. There has been significant development wrt to performance of markers. Please make sure you use the latest version.

8000 markers are quite significant. Please show us the code snippet you are using to add the markers.

I use the TMSFNCGoogleMaps komponent (1.0.4.1) and add all (German) ZIP Codes from a table to a cluster.

procedure TMapIt.DBtoMAP;
begin
  TMSFNCMaps1.BeginUpdate;

  with MarkerTable do begin
    First;
    while not MarkerTable.EOF do begin
      // TMSFNCMaps1.AddMarker(FieldByName('LAT').Value, FieldByName('LON').Value, FieldByName('ZipCode').Value, '');
      CreateClusterMarker(FieldByName('ZipCode').Value, FieldByName('LAT').Value, FieldByName('LON').Value, eu,'');
      Next
    end;
  end;

  TMSFNCMaps1.EndUpdate;
end;

procedure TMapIt.CreateClusterMarker(ATitle: string; ALatitude,
  ALongitude: Double; AGroup: TTMSFNCGoogleMapsCluster; AIconName: string);
var
  m: TTMSFNCGoogleMapsMarker;
begin
  m := TMSFNCMaps1.Markers.Add;
  m.Longitude := ALongitude;
  m.Latitude := ALatitude;
  m.Title := ATitle;
  m.Cluster := AGroup;

  AGroup.Markers.Add(m);
end;

procedure TMapIt.InitGroups;
begin
  TMSFNCMaps1.BeginUpdate;

  TMSFNCMaps1.Markers.Clear;
  TMSFNCMaps1.Clusters.Clear;


  eu := TMSFNCMaps1.Clusters.Add;
  eu.Title := 'Europe';
  af := TMSFNCMaps1.Clusters.Add;
  af.Title := 'Africa';
  asia := TMSFNCMaps1.Clusters.Add;
  asia.Title := 'Asia';
  na := TMSFNCMaps1.Clusters.Add;
  na.Title := 'North-America';
  sa := TMSFNCMaps1.Clusters.Add;
  sa.Title := 'South-America';
  oc := TMSFNCMaps1.Clusters.Add;
  oc.Title := 'Oceania';


  TMSFNCMaps1.EndUpdate;
end;
```[MontPos.zip|attachment](upload://i02Ijyc9jzRClEI5JjBMBtv5yi2.zip) (377.9 KB) 

The source code is included as a zip file.

When I call INIGroups and DBtoMAP in one Step, the markers are drawn twice.
If I call INIGroups first and then the DBtoMAP, everything is ok.
I guess it is better to send the data as a JSON-file.

Hi,

Can you please try the following?

Move the BeginUpdate and EndUpdate call outside of the InitGroups and DBToMap procedures.

Example:

procedure TForm1.Button1Click(Sender: TObject);
begin
  TMSFNCMaps1.BeginUpdate;
  InitGroups;
  DBToMap;
  TMSFNCMaps1.EndUpdate;
end;