use mapview on standard tabcontroller

Hi,


is it possible to use the TMS mapview on a standard fmx ttabcontrol?

Reason: the code should remain as standard as possible. Only the mapview is a requirement, and this should be the only part that should be changed when targetting other platforms in the future.

Problem: the map doesn't draw. The control is clearly inserted at the correct place, but it doesn't draw its map.


Best regards,

Jan

The TTabcontrol is the XE4 tabcontrol, not the TMS tabcontrol.

To reproduce this:


 - Create a new blanc firemonkey mobile app
- Drop a TTabControl on the form, set it to alClient
- Add 2 tabs
- Add the mapview as subcontrol of one of the tabitems


--> The mapview doesn't draw



Unfortunately no, 


Everything in FireMonkey is drawn directly on the root view of the application. The MapView component is a real native iOS Control that is added as a subview of the rootview, so if you try to add it as a child of a FireMonkey control, the MapView will not be displayed. 

What you can do, since the FireMonkey controls are drawn first, and the native iOS controls are placed on top of the root view drawing, is handling the Tab change and toggling the MapView visibility. the MapView need to be placed on top of the TabControl and the bounds set to match the bounds of the TabPage.

Kind Regards, 
Pieter
A Sample would be:

Drop a TMSFMXNativeMkMapView on the form
Drop a TabControl on the form
Add 2 tab items and the following code:

procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFMXNativeMKMapView1.Visible := False;
  TMSFMXNativeMKMapView1.SetBounds(TabControl1.Position.X, TabControl1.Position.Y, TabControl1.Width, TabControl1.Height - TabControl1.TabHeight);
end;

procedure TForm1.TabControl1Change(Sender: TObject);
begin
  TMSFMXNativeMKMapView1.Visible := TabControl1.ActiveTab = TabItem2;
end;

Please also read the following blog post about TMS iCL:


http://www.tmssoftware.com/site/blog.asp?post=266

Thanks Pieter,


your sample helped me to produce a workable app!

Best regards,

Jan

Thank you !

Hi Pieter,


in XE5 this doesn't seem to work anymore. Can you confirm this? Do you know about a workaround?


Best regards,

Jan

Please define, doesn't work anymore?

Pieter,


let me clarify:

In XE4 I used a trick, where I create 3 forms
- A: master form with tabcontrol (2 tabitems)
- B: child form with tlayoutcontrol
- C: child form with tlayoutcontrol

Upon application start I set the parent of the layoutcontrols of the subforms (B & C) to the tabitems on the mainform (A). This resulted in a nice interface, and clean code separation. 

Form A also contained the mapview, which I set visible using the trick mentioned above, with bounds set to tabitem2. This setup worked flawless

In XE5 this functionality seems broken, the mapview will not show anymore in this setup. It still works when I remove the parenting trick, so it is related to this trick I think. I now merged my code into 1 big form. Less clean, but it works.

Best regards,

Jan
Hi, 

There is a known bug creating forms in XE5, which might be the cause for this issue.
We haven't found a workaround for this yet and will need to be fixed by Embarcadero.

Kind Regards, 
Pieter