Heatmap - DoCustomizeMap

I followed the blog to create the heatmap from a collection of points and that works when I first startup the map. But, what do I do while running the program if I want to change the points?

What do I call against the map to cause it to fire the DoCustomizeMap routine?

I want to be able to turn the heatmap on or off as needed and change the points.

Something like this:

//*************************************************************************
//
// ExtendedGoogleMaps - Override DoCustomMap
//
//
procedure TTMSFNCGoogleMapsEx.DoCustomizeMap(var ACustomizeMap: string);
var
h: string;
begin
h:='';
if FMain.HeatMapStr<>'' then
h:=FMain.HeatMapStr;
ACustomizeMap := h;
inherited;
end;

So, what do I call against the map to have it run through this routine?

If you call TMSFNCGoogleMaps1.Reinitialize, this will call OnCustomizeMap again.

For those that may need it, I ended up writing my own method for generating a heatmap - rather than using the DoCustomizeMap routine.

//*****************************************************************************
//
// TurnOffHeatMap
//
//
procedure TFFuncs_GoogleFNC.TurnOffHeatMap;
var NewHeatMapStr:string;
begin
FMain.HeatMapStr:=''; // Clear the global variable
NewHeatMapStr:='heatmap.setMap(null);'+LB; // Turn off the Heatmap
FMain.FNCGoogleMaps.ExecuteJavaScript( // Execute the script
NewHeatMapStr);
end;
//*****************************************************************************
//
// CreateHeatMapStr
//
//
procedure TFFuncs_GoogleFNC.CreateHeatMapStr(MyMarkers: TGMMarker;
EnableIt: Boolean);
var i:integer;
MyLat,MyLon,
NewHeatMapStr:string;
begin
TurnOffHeatMap; // Regardless, disable HeatMap

if not EnableIt then // Not enabling it, just exit
Exit;

NewHeatMapStr := 'var heatMapData = [' + LB; // Begin the Lat/Lon Points

if MyMarkers.Count>0 then
begin
for i:= 0 to MyMarkers.Count-1 do // Loop through the Markerset
begin
MyLat:=FloatToStr(MyMarkers[i].Position.Lat);
MyLon:=FloatToStr(MyMarkers[i].Position.Lng);
NewHeatMapStr := NewHeatMapStr+
'{location: new '+MAPSERVICEVAR+ // Specify a new location
'.LatLng('+MyLat+', '+MyLon+'),'+ // Lat/Lon
' weight: 1'+'}'; // Set weight to 1 - for all
if i<MyMarkers.Count-1 then // Add a comma except for the
NewHeatMapStr := NewHeatMapStr+','; // last record
NewHeatMapStr := NewHeatMapStr+LB;
end;
end;

NewHeatMapStr := NewHeatMapStr+ // Add the HeatMap object
'];' + LB +
'var heatmap = new ' + MAPSERVICEVAR + // new 'heatmap' object
'.visualization.HeatmapLayer({' + LB +
' data: heatMapData' + LB + // pass the 'heatMapData'
'});' + LB +
'heatmap.setMap(' + MAPVAR + ');'+LB+ // Turns on the HeatMap
'heatmap.set('+#34+'opacity'+#34+',0.8);'+LB+// Set the opacity to 0.8
'heatmap.set('+#34+'radius'+#34+',25);'; // Set the radius to 25 pixels

// TraceMsg(LB+NewHeatMapStr+LB);
FMain.HeatMapStr:=NewHeatMapStr; // Set the global variable
FMain.FNCGoogleMaps.ExecuteJavaScript( // Execute the Script
NewHeatMapStr);
end;