Script-Error on inserting Marker in Cluster

hi,
i get a Script-Error when trying to insert a marker to a cluster:

this leads to error:
var m: TMarker;
begin
   WebGMaps1.Clusters.Add;
   m := WebGMaps1.Markers.Add;
   m.Latitude := 49;
   m.Longitude := 2;
   m.Title := 'Test';
   m.Cluster:=WebGMaps1.Clusters[0].Cluster;
   WebGMaps1.CreateMapCluster(WebGMaps1.Clusters[0].Cluster);

the funny thing is, that this is working:
var m: TMarker;
begin
   WebGMaps1.Clusters.Add;
   m := WebGMaps1.Markers.Add(49, 2, 'Test');
   m.Cluster:=WebGMaps1.Clusters[0].Cluster;
   WebGMaps1.CreateMapCluster(WebGMaps1.Clusters[0].Cluster);

what am i doing wrong?

Hi,


Please note that using the Markers.Add call without parameters will not automatically add the marker to the map, but only to the Markers collection.
It is required that the marker is added to the map before the CreateMapCluster call is used.
You can add the marker to the map with the CreateMapMarker(MarkerId) call.


ok, thank you.

after playing around with the marker clusters i see no advantage in speed/performance, wher creating large clusters.
for example: showing 5000 markers on a map with a cluster is even slower, than without a cluster.

var x: Integer;
    lat, lng: Double;
    m: TMarker;
begin
   WebGMaps1.Clusters.Add;
   for x:=1 to 5000 do begin
      lat:=48.45904 + (random(800)/1000);
      lng:=1.794297 + (random(1000)/1000);
      m:=WebGMaps1.Markers.Add(lat, lng, 'Testmarker '+IntToStr(x));
      m.Cluster:=WebGMaps1.Clusters[0].Cluster;
   end;
   WebGMaps1.CreateMapCluster(WebGMaps1.Clusters[0].Cluster);
end;

it seems like the markers are first placed on the map and then grouped in clusters.
what is the correct/fastest way to build a large marker cluster?
am i missing again something?

Using marker clusters only provides a visual advantage, there is no performance advantage.
As far as i know this is a limitation of the marker cluster API which we have no control over.