TMarkers in Collection and on Map


How are functions related to Collections, Map and each other?

My example (3 buttons with the same OnClick)

procedure TForm1.Button2Click(Sender: TObject);
  cnstDEF_LAT = 2.4;
  cnstDEF_LON = 37.6;
  cnst_OFF    = 2;
  m: TMarker;
  Assert(Sender is TButton);

  for i:=Ord(Low(TMarkerShape)) to Ord(High(TMarkerShape)) do begin
    if (Sender as TButton).Tag = cnstMAV1 then
      m := WebGMaps1.Markers.Add()
      m := WebGMaps1.Markers.Add(cnstDEF_LAT+(i*cnst_OFF), cnstDEF_LON);

    with m do begin
      Title     := Format('%s:%d',['Title',i]);
      Clickable := True;
      Draggable := True;
      Flat      := True;
      Latitude  := cnstDEF_LAT+(i*cnst_OFF);
      Longitude := cnstDEF_LON;

      Shape             := TMarkerShape(i);
      ShapeColor        := clYellow;
      ShapeBorderColor  := clGreen;
      ShapeScale := 2.0;
    if (Sender as TButton).Tag = cnstMAV3 then

  WebGMaps1.MapPanTo(cnstDEF_LAT, cnstDEF_LON);
  WebGMaps1.MapOptions.ZoomMap :=5;

Empty Map, Markers are not displayed!


10 Makers, Ok, but the same shape at all!


I counted 18 Makers, should be 10?

With the TMSVCLWebGMapsDevGuide.pdf , I can’t understand internal processes; also, the doc has not been updated for a long time (for example, see Page 27 below)
The given example has an error in the number of arguments.

Thanks in advance.


Please note the following:

- The call Markers.Add() will add a marker to the Markers collection, but not the map itself.
To add the marker to the map, you should also call CreateMapMarker(MarkerID) after configuring the marker properties.

- The call Markers.Add(Latitude, Longitude) will automatically add the marker to the map but will not automatically update the marker if the Shape properties has changed. You can call UpdateMapMarker(MarkerID) to update an existing marker.

- The call Markers.Add(Latitude, Longitude) will automatically add the marker to the map as wel as the Markers collection. Calling CreateMapMarker(MarkerID) afterwards will result in 2 markers displayed on the map.

Thank you for notifying us about the error in the doc, this will be corrected as soon as possible.

Bart, thanks!

Now it is more understandable; let me continue my "questions."

How are the Markers bind in the Collection and on the Map?
As far as I understand, it should be a type of bind: one to many, .i.e. can create many Markers on a Map from one Marker in the Collection, and their connections should be permanent.

I get something else, for example:
step 1:
m := WebGMaps1.Markers.Add()
step 2:
(one Marker on the Map)
step 3:
(two Markers on the Map)
step 4:
(one Marker remains on the Map but WebGMaps1.Markers.Count=0)

How Markers in the Collection and on the Map linked?
If there is no hard link between them, how to access the Map Markers, that are not associated with the Collection?
...except DeleteAllMapMarker


You can indeed call CreateMapMarker for the same MarkerID multiple times and multiple markers will be displayed on the map.
However this is not the intended usage of CreateMapMarker because, as you demonstrated, links to all markers on the map except the first marker will be lost.

If you want to preserve links to markers on the map, make sure to only create a marker once for each item in the Markers collection.

Ok, let's continue

step 1:

m:=Markers.Add(LAT, LON);
Draggable := True;

(marker(s) on Map with correct shape, hint and draggable; Ok)
step 2:


(no markers on Map, Ok)
step 3:
Repeat step 1
(one marker(s) on Map with the wrong shape, no hint, not draggable; Error)

What am I doing wrong?

Note that DeleteAllMapMarker will only remove the markers from the map, but not the Markers collection.
Please make sure to clear the Markers collection as well.

If we use
WebGMaps1.Markers.Add(<no params>)
feel free in actions; in any order can: 
add markers to Collection (via Markers.Add())
add markers to Map (via CreateMapMarker)
(Warning: only create a marker once for each item in the Markers collection)
delete markers from Map (via DeleteAllMapMarker)

If we use 
WebGMaps1.Markers.Add(<with params) and UpdateMapMarker
can not use DeleteAllMapMarker
Only Markers.Clear and repeat all steps from the beginning

Chaotic, so have to remember.

Inexplicable behavior

I use combination
Polygons. Add
from the drop-down menu, depending on the mouse pointer location, everything is okay, or everything is not working.

If mouse pointer, after drop-down MenyItem Click, stays in the map area not occupied by the Polygon - everything is OK.

If the mouse pointer remains over any Polygon, then Polygons lose their properties, and these properties no longer restored until the program reloaded.
On the last picture, Polygons have "lost", at least,  Editable and Hint properties.

Test app, llink valid till 11.01.19
Please, add your key in to INI-file

I can confirm I have been able to reproduce this issue.
We are now investigating it and will report back as soon as possible.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.