Is there a map library working with Compose Deskto...
# compose-desktop
j
Is there a map library working with Compose Desktop? I am thinking something like GoogleMaps, Mapbox or MapLibre. I saw people online mentioning MapLibre (or was it Mapbox?), and issues related to the fact that it uses OpenGL. With Android, it uses a GLSurfaceView... doesn't that exist with Compose Desktop? I was looking at https://maplibre.org/maplibre-native/docs/book/design/ten-thousand-foot-view.html, but I am having a hard time evaluating if this would be a feasible side-project, or if that's a 6 months task for an experienced Compose/Maplibre developer 😁. Any pointers are welcome!
👆 1
b
j
I had realized that the channel is not very active, but if I had known that I would be spammed on my first message, I wouldn't have bothered.
b
Don't take it so personally
As for your initial question, you might have better luck in finding an answer if you clarify what's the actual ask here. Are you evaluating the complexity of writing kn bindings for maplibre or are you thinking of mapping maplibre and something else to build a kmp library with common api surface? Something else entirely??
j
MapLibre (forked from Mapbox) has a C++ engine for rendering maps. They have Android bindings (not to Compose, just to Java).
b
For CfD you could try JxBrowser via compose swing interop https://dzone.com/articles/google-maps-java-swing
j
Since the engine currently renders to OpenGL, the Android layer somehow ends up creating a GLSurfaceView and passing it to the C++ core (I am not yet completely clear on the implementation details).
I see a GLSurfaceView on Android as a box, to which Android will forward events (that may or may not be consumed by the surface), and on top of which Android may or may not draw stuff. Android doesn't know about the actual texture rendered in this Surface, that's just a box with "some texture".
That's fine for Android, but now I wonder: how do I do that with Compose Desktop? Is there a notion of a surface, to which "something" renders, and that may consume touch events (or mouse events, for Dekstop)?
b
There must be as it uses the same skia engine
j
You mean, Compose Desktop uses the same skia engine as Android Compose?
b
Is this what you're after? https://stackoverflow.com/a/67038959
j
(sorry if I'm being vague, I'm trying to get keywords at this stage 😄)
Is the concept of native canvas you linked above related to OpenGL / skia? It seems pretty high level, but I can look how low-level its interface goes.
b
Not sure tbh
j
I guess I am looking for the equivalent of GLSurfaceView on Compose Desktop, but maybe I should now have a closer look at how this GLSurfaceView ends up being used
Thanks for the help
b
tenor_gif2066954490307115694.gif
j
Hmm Canvas seem higher level than OpenGL. Seems to me that it is not possible to integrate MapLibre/Mapbox with Compose Desktop. Maybe someday.
l
You can embed Swing components in CfD, so if there's a good Swing library, I'd use that.
j
Let me be more specific: I actually don't need to write a Compose for Desktop app that shows a map: I want to understand what it would involve to integrate a map engine like Mapbox/MapLibre with Compose for Desktop. MapLibre/Mapbox render with OpenGL, so at some point I need some kind of construct in Compose for Desktop that can interface with that.
Seems like the lowest-level I can get with Compose is Canvas, which is an abstraction above the renderer.
So yeah, seems like it's not possible.
l
I used ffmpeg to build a video player in Compose for Andriod and iOS at my last job. It's definitely possible. I would recommend taking a look at some low level drawing APIs.
For example, in CfD, you can access nativeCanvas (you can access nativeCanvas in any platform, but it's different). If you can get an array of ARGB values, you can use that for rendering.
j
Is there some documentation / code I could read about that? I read the API definition of nativeCanvas but... still a bit unclear to me how to render an ARGB array
A video player would be a cool exercise, actually 🙂
t
Here i presented a prototype for video player which uses an ARGB array to show video: https://kotlinlang.slack.com/archives/C01D6HTPATV/p1687168672359469
When you go to the thread i also pointed out the code lines which does the image copying
In general i think that CfD lacks possibilities to integrate it with other libraries you need to get many multimedia things done. I know CfD is not an multimedia framework. But who wants to build apps that are not able to playback video or show a map?
👍 1
153 Views