Map is sometimes not loaded when using within Frame

We have the issue that sometimes the map isn't loaded when it is placed within a frame that is dynamically loaded.

Steps to reproduce:

  • Create a Frame with TMSFNCGoogleMaps placed on it and set the API-Key
  • Create a Dialog with a Button
  • Within the Click-Event of the Button create the frame and assign a parent to it
  • Make sure to start the program without debugger as it only happens without it

Here's the code:

__fastcall TFormMain::TFormMain(TComponent* Owner)
	: TForm(Owner)
{
//	this->m_pFrameStandort = std::make_unique<TFrameStandort>(this);
}
//---------------------------------------------------------------------------

void __fastcall TFormMain::Button1Click(TObject *Sender)
{
	this->m_pFrameStandort = std::make_unique<TFrameStandort>(this);
	this->m_pFrameStandort->Parent = this;
	this->m_pFrameStandort->Align = alClient;
}
//---------------------------------------------------------------------------

If i change create the Frame in the constructor and not in the Click-Event it seems to work:

__fastcall TFormMain::TFormMain(TComponent* Owner)
	: TForm(Owner)
{
	this->m_pFrameStandort = std::make_unique<TFrameStandort>(this);
}
//---------------------------------------------------------------------------

void __fastcall TFormMain::Button1Click(TObject *Sender)
{
//	this->m_pFrameStandort = std::make_unique<TFrameStandort>(this);
	this->m_pFrameStandort->Parent = this;
	this->m_pFrameStandort->Align = alClient;
}
//---------------------------------------------------------------------------

MapsTest.zip (28.2 KB)

Please note that this is a technical limitation when using the TTMSFNCWebBrowser (which TTMSFNCMaps is based on) in combination with Frames.

A possible workaround is to call ReInitialize on the TTMSFNCMaps control after the frame is loaded.

Example:
TTMSFNCMaps(fr.Controls[0]).ReInitialize

I wasn't aware of that. Thank you for the clarification. Is there any information why this is the case? Just for my understanding :slight_smile:

Thank you!

I tried the whole day. And it seems rather difficult to use the Maps when i wan't it to embedd from a frame or dialog into another dialog.

I ended up doing the following, which finally seems to work:

In my dialog where i want to use the Maps-Component i create the new Dialog within the constructor:

__fastcall TFormProjekt::TFormProjekt(TComponent *Owner) : TForm(Owner)
{
    FormStandort = new TFormStandort(Application);
}

At some point i set the dialog:

    FormStandort->BorderStyle = bsNone;
    FormStandort->Caption = L"";
    FormStandort->Parent = this->panDaten;
    FormStandort->Align = alClient;
    FormStandort->Visible = true;

And in the FormShow-Event i do the following:

    this->wgmStandort->ReInitialize();
    this->wgmStandort->Options->DefaultZoomLevel = 15;
    // Set-Function is creating Markers, etc.
    this->Set(this->m_strAuftrNr);