I have an application that has a button that, when clicked, runs a query, then reads through the dataset and adds markers to a TGMMap/TGMMarker corresponding to the values read (it also uses a TGMGeoCode to geocode address values, if that matters). The first time that the button is clicked, the correct number (10) of markers is always placed, but if I click the button again right after the points are shown, a random number of markers is drawn (sometime 3, sometimes 1, sometimes 5, etc.). However, if I wait for some time (about 15-20 seconds) before clicking the button again, the correct number of points is always drawn, so I'm sure that it's some kind of timing issue where the DOM is maybe not fully built or some script is still executing or ??? Is there some kind of status flag that I can check to make sure that the map is ready to accept new markers, or is there some kind of ProcessMessage loop that I need to implement or ??
The code basically works like this every time the button is clicked:
dataSet.Active := false;
dataset.Active := true;
Marker1.Clear();
while (dataset.Eof=false) do
begin
fGeoCoder.Geocode(address);
// Use first GeoCode result??
if (fGeoCoder.GeoStatus = gsOK) and (fGeoCoder.Count > 0) then
begin
geoResult := fGeoCoder.GeoResult[0];
lat := geoResult.Geometry.Location.Lat;
lng := geoResult.Geometry.Location.Lng;
marker := Marker1.Add(lat, lng);
end;
dataset.Next();
end;
Thanks in advance for any help you can provide.