https://kotlinlang.org logo
#compose
Title
# compose
m

myanmarking

03/31/2022, 8:54 AM
in compose map, how do i get a screenshot of the map, as in:
snapshot(@NonNull GoogleMap.SnapshotReadyCallback callback) ?
o

Oleksandr Balan

04/01/2022, 1:25 PM
What do you mean by “compose map”? You want to take a screenshot from the Google Map?
m

myanmarking

04/01/2022, 2:50 PM
Legacy GoogleMap has a method
snapshot
which generates a bitmap of the map content. Compose version has no such method, nor indirect access to GoogleMap instance.
o

Oleksandr Balan

04/01/2022, 3:00 PM
Aha, then I am not aware of the compose version of ot 😅 In our recent project we do use normal GoogleMap and use snapshot method to take a screenshot Moreover our use case was just to use a map to take a screenshot and then show a bitmap instead of a map
Is it something you want to achieve? Or is your use-case different?
m

myanmarking

04/01/2022, 3:03 PM
i just ported the map code to compose and it worked flawlessly for everything. But i forgot that we had a feature that required a snapshot of the map. I didn’t realise until the end. It looks like compose map library doesn’t have that feature yet. I solved the problem by accessing the legacy GoogleMap with reflection and invoking
snapshot
method.
o

Oleksandr Balan

04/01/2022, 3:22 PM
Ah, I get it, I did not work with the compose version of the map, sry :/
11 Views