Jump to content
MikeZ87

Save MapView image to bitmap

Recommended Posts

Greetings,

 

I have a TMapView component on my firemonkey (android) form. It gets the map image nicely, and I can scroll, zoom in, etc...

 

I need to be able to save that mapview image to storage on an android app, and I'm having no luck. I can't even copy it to another TImage component.

 

Can anyone help me with this?

 

- How can I save the mapview image to local storage on the android?

- How can I copy the mapview image to another image component?

 

I've tried things like image1.assign(mapview1.MakeScreenShot) to copy, and MapView1.MakeScreenShot.SaveToFile(filename), but neither of those work. (Assign doesn't do anything, and SaveTo results in an error.

 

Any help would be appreciated.

 

Thanks!

Share this post


Link to post
1 hour ago, MikeZ87 said:

I've tried things like image1.assign(mapview1.MakeScreenShot) to copy, and MapView1.MakeScreenShot.SaveToFile(filename), but neither of those work. (Assign doesn't do anything, and SaveTo results in an error.

You need to use the Snapshot method: https://docwiki.embarcadero.com/Libraries/Alexandria/en/FMX.Maps.TCustomMapView.Snapshot

  • Like 1

Share this post


Link to post

Thanks for the lead, Dave. I'm not really sure how to use that, and googling for help on it (with examples) doesn't yield any code. Could you give me an example?

Share this post


Link to post
46 minutes ago, MikeZ87 said:

I'm not really sure how to use that

I'm not sure what is unclear about it. The method takes a single parameter that is an object method with a single parameter that is a TBitmap: https://docwiki.embarcadero.com/Libraries/Alexandria/en/FMX.Maps.TMapScreenshotRecipient 

i.e. you would declare a method on an object (such as the form that contains the MapView), and pass that when calling Snapshot, e.g:

procedure TForm1.SnapshotRecipient(const ABitmap: TBitmap);
begin
  // Do whatever you will with ABitmap, here
end;

..and call Snapshot like this, for example:

MapView1.Snapshot(SnapshotRecipient)

 

  • Like 1

Share this post


Link to post

Hi Dave,

 

OMG!!! THAT WORKED!!! You're my HERO!!! THANK YOU!!! I'm learning more and more Delphi every day, and **THIS** is huge! THANK YOU!!!

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×