Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Menu with listbox and map



Permlink Replies: 13 - Last Post: Jun 19, 2017 5:49 PM Last Post By: Andrew Hodson
Andrew Hodson

Posts: 39
Registered: 8/23/10
Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 9, 2017 1:40 PM
I have been following this example:

https://community.embarcadero.com/article/articles-tutorials/151-ui/922-create-an-action-bar-with-overflow-menu-on-android-by-sarina-dupont

But i have a MapView component on it and it seems to obscure the listbox. I have tried sending the listbox to the top but no luck. Any ideas?
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 9, 2017 2:23 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Andrew Hodson wrote:

But i have a MapView component on it and it seems to obscure the listbox. I have tried sending the listbox to the top
but no luck. Any ideas?

Z-Order issues. Fixes for them are on the roadmap, however for now you'll need to set the MapView invisible while the
ListBox is showing.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Andrew Hodson

Posts: 39
Registered: 8/23/10
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 9, 2017 7:31 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Andrew Hodson wrote:

But i have a MapView component on it and it seems to obscure the listbox. I have tried sending the listbox to the top
but no luck. Any ideas?

Z-Order issues. Fixes for them are on the roadmap, however for now you'll need to set the MapView invisible while the
ListBox is showing.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

So the question becomes how can I add a menu to my app?
Francesco Marano

Posts: 59
Registered: 11/18/02
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 9, 2017 7:43 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Any ideas?

Hello,

Please consider to take a snapshot of the screen (e.g. when MapView is shown: MapView.MakeScreenshot), then hide the MapView control, show the screenshot and add a menu (e.g. a popup) on top of that.

Regards, Francesco
Andrew Hodson

Posts: 39
Registered: 8/23/10
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 11, 2017 3:05 PM   in response to: Francesco Marano in response to: Francesco Marano
Francesco Marano wrote:
Any ideas?

Hello,

Please consider to take a snapshot of the screen (e.g. when MapView is shown: MapView.MakeScreenshot), then hide the MapView control, show the screenshot and add a menu (e.g. a popup) on top of that.

Regards, Francesco

Have tried this:

Image1.Bitmap.Assign(MapView1.MakeScreenshot);
Mapview1.Visible:=Not MapView1.Visible;

But the image doesn't display. What am i doing wrong?
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 11, 2017 5:02 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Andrew Hodson wrote:

Image1.Bitmap.Assign(MapView1.MakeScreenshot);
Mapview1.Visible:=Not MapView1.Visible;

But the image doesn't display. What am i doing wrong?

For TMapView you need to call the SnapShot method, like this:

  MapView1.Snapshot(
    procedure(const ABitmap: TBitmap)
    begin
      Image1.Bitmap.Assign(ABitmap);
    end
  );


It uses the GoogleMap.SnapshotReadyCallback, which according to the documentation:

https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.SnapshotReadyCallback

The callback happens on the UI thread, so there should be no need to call Synchronize.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Andrew Hodson

Posts: 39
Registered: 8/23/10
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2017 2:03 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Andrew Hodson wrote:

Image1.Bitmap.Assign(MapView1.MakeScreenshot);
Mapview1.Visible:=Not MapView1.Visible;

But the image doesn't display. What am i doing wrong?

For TMapView you need to call the SnapShot method, like this:

  MapView1.Snapshot(
    procedure(const ABitmap: TBitmap)
    begin
      Image1.Bitmap.Assign(ABitmap);
    end
  );


It uses the GoogleMap.SnapshotReadyCallback, which according to the documentation:

https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.SnapshotReadyCallback

The callback happens on the UI thread, so there should be no need to call Synchronize.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

Can you expand a bit on how to do this please
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2017 2:41 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Andrew Hodson wrote:

Can you expand a bit on how to do this please

Sorry, the example I gave was wrong. This will compile, and should work:

procedure TForm1.Button1Click(Sender: TObject);
begin
MapView1.Snapshot(SnapshotHandler);
end;

procedure TForm1.SnapshotHandler(const ABitmap: TBitmap);
begin
Image1.Bitmap.Assign(ABitmap);
end;

Note: This does not work on iOS simulator for one reason or another.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Andrew Hodson

Posts: 39
Registered: 8/23/10
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 18, 2017 1:09 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Andrew Hodson wrote:

Can you expand a bit on how to do this please

Sorry, the example I gave was wrong. This will compile, and should work:

procedure TForm1.Button1Click(Sender: TObject);
begin
MapView1.Snapshot(SnapshotHandler);
end;

procedure TForm1.SnapshotHandler(const ABitmap: TBitmap);
begin
Image1.Bitmap.Assign(ABitmap);
end;

Note: This does not work on iOS simulator for one reason or another.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

Still won't work. How can i get MapView1 to have a Snapshot method?
Andrew Hodson

Posts: 39
Registered: 8/23/10
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 18, 2017 1:23 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Andrew Hodson wrote:
Dave Nottage wrote:
Andrew Hodson wrote:

Can you expand a bit on how to do this please

Sorry, the example I gave was wrong. This will compile, and should work:

procedure TForm1.Button1Click(Sender: TObject);
begin
MapView1.Snapshot(SnapshotHandler);
end;

procedure TForm1.SnapshotHandler(const ABitmap: TBitmap);
begin
Image1.Bitmap.Assign(ABitmap);
end;

Note: This does not work on iOS simulator for one reason or another.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

Still won't work. How can i get MapView1 to have a Snapshot method?

Sorry. My mistake. works now
Andrew Hodson

Posts: 39
Registered: 8/23/10
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 19, 2017 1:57 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Andrew Hodson wrote:
Andrew Hodson wrote:
Dave Nottage wrote:
Andrew Hodson wrote:

Can you expand a bit on how to do this please

Sorry, the example I gave was wrong. This will compile, and should work:

procedure TForm1.Button1Click(Sender: TObject);
begin
MapView1.Snapshot(SnapshotHandler);
end;

procedure TForm1.SnapshotHandler(const ABitmap: TBitmap);
begin
Image1.Bitmap.Assign(ABitmap);
end;

Note: This does not work on iOS simulator for one reason or another.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

Still won't work. How can i get MapView1 to have a Snapshot method?

Sorry. My mistake. works now

My mistake again. Can't get image saved. Any ideas why not?
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 19, 2017 2:04 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Am 19.06.2017 um 22:57 schrieb Andrew Hodson:


My mistake again. Can't get image saved. Any ideas why not?

Can you show code?
Where do you want to save it to?

Greetings

Markus
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 19, 2017 3:27 PM   in response to: Andrew Hodson in response to: Andrew Hodson
Andrew Hodson wrote:

My mistake again. Can't get image saved. Any ideas why not?

Which version of Delphi do you have?

The code I showed works for on iOS 10.3.1 using Delphi Tokyo. I haven't tested it on Android, as there's some
hoop-jumping to go through in order to use TMapView on Android.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Andrew Hodson

Posts: 39
Registered: 8/23/10
Re: Menu with listbox and map
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 19, 2017 5:49 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Andrew Hodson wrote:

My mistake again. Can't get image saved. Any ideas why not?

Which version of Delphi do you have?

The code I showed works for on iOS 10.3.1 using Delphi Tokyo. I haven't tested it on Android, as there's some
hoop-jumping to go through in order to use TMapView on Android.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com

I am using XE8
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02