Google MAPS Erroros

When I use a current (new) Google Maps API key, I get the following errors:

  1. InvalidValueError: setCenter: not a LatLng or LatLngLiteral with finite coordinates: in property lat: not a number
  2. InvalidValueError: setMap: not an instance of Map; and not an instance of StreetViewPanorama
    It works perfectly with the old key.
    Is it possible that Google has changed something in the API and this hasn't yet been reflected in the TMS Web Core?

I found another warning in the console:
As of February 21st, 2024, google.maps.Marker is deprecated. Please use google.maps.marker.AdvancedMarkerElement instead. At this time, google.maps.Marker is not scheduled to be discontinued, but google.maps.marker.AdvancedMarkerElement is recommended over google.maps.Marker. While google.maps.Marker will continue to receive bug fixes for any major regressions, existing bugs in google.maps.Marker will not be addressed. At least 12 months notice will be given before support is discontinued. Please see Deprecations  |  Google Maps Platform  |  Google for Developers for additional details and Migrate to advanced markers  |  Maps JavaScript API  |  Google for Developers for the migration guide.

I retested this here with a brand new created API key and I see no problem with calling:

procedure TForm2.WebFormCreate(Sender: TObject);
begin
WebGoogleMaps1.APIKey := MY_NEW_KEY;
end;

procedure TForm2.WebButton1Click(Sender: TObject);
begin
WebGoogleMaps1.SetCenter(50.8,3.16667);
end;

What are you doing different?

We see the warning in the console for:

procedure TForm2.WebButton1Click(Sender: TObject);
begin
WebGoogleMaps1.AddMarker(50.8,3.16667, 'Wevelgem');
end;

It is not critical at this moment but it is on our todolist to revisit the underlying used Google Maps API call.

I found the problem. This error occurs when you enter a key in the properties and then assign a different key at runtime.
Is it possible to load the map asynchronously (as suggested by Google)?

A possible solution for this case is to destroy the map control via code and recreate it with code and set the new API key.