mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Official support for Jetpack Compose

Open VincentJoshuaET opened this issue 4 years ago • 8 comments

This comes in a great combination with Mapbox v10's Kotlin first design.

VincentJoshuaET avatar Feb 25 '21 00:02 VincentJoshuaET

Hey folks :wave: I played around with Compose to build an app and ran into this exact issue, too. The main question is how to adapt the imperative apis the map provides for a declarative world modern user interfaces are moving towards.

Ideally we'd have a declarative map wrapper taking a viewport from the parent component (composable), then

  • the map component is stateless and its appearance only gets controlled by the properties passed in, and
  • the viewport property acts as a single source of truth for the map's appearance throughout the app

The most basic use-case would then look like this on the call site

val (viewport, setViewport) = remember { mutableStateOf(initialViewport) }

Map(viewport = viewport, onViewportChange = setViewport)

I've built a declarative wrapper around the map for my own use case; you can find a very basic version here

https://gist.github.com/daniel-j-h/cd88b6cdf54e86bffed2bc440cbbb751

Side note: this is similar to https://github.com/visgl/react-map-gl (are we full circle yet :upside_down_face:) and it would be great to have support within this project, instead of smaller wrapper projects (like react-map-gl) popping up.

daniel-j-h avatar May 25 '21 11:05 daniel-j-h

Compose is now stable

VincentJoshuaET avatar Jul 29 '21 00:07 VincentJoshuaET

https://github.com/googlemaps/android-maps-compose

Take a look at this and copy/paste their solution ;-)

ghost avatar Feb 04 '22 15:02 ghost

I've played around with building a Compose for Web wrapper around mapbox-gl-js. The implementation still needs work, but I think the general compose-level API design is decent.

The map is controlled through a MapboxState object which, for example, allows the different camera methods to be called. The map's sources, layers, and styles are implemented as a separate compose tree in order to properly integrate with the Map's separate lifecycle and also maintains a nice DSL for constructing the map.

I haven't tried yet, but I'm sure the same kind of thing could be implemented with Jetpack Compose and the Android Maps SDK.

dellisd avatar Feb 04 '22 18:02 dellisd

Any official updates regarding this?

warting avatar Mar 21 '22 12:03 warting

Any official updates regarding this?

Hi, no updates at the moment.

yunikkk avatar Mar 22 '22 15:03 yunikkk

Will this ever be possible to have a a Mapbox application without any XML layouts and AndroidViews?

VincentJoshuaET avatar Oct 13 '22 05:10 VincentJoshuaET

There is a prototype for a compose interface here

  • https://github.com/mapbox/mapbox-maps-android/pull/1443

It looks like it hasn't moved in the last four months, tho.

daniel-j-h avatar Oct 13 '22 09:10 daniel-j-h

Looking forward to seeing it being supported. Is there any timeline on official support for Jetpack Compose?

patrick-fitzgerald avatar Jan 30 '23 05:01 patrick-fitzgerald

Waiting for the official support too!

Lizzergas avatar Feb 06 '23 13:02 Lizzergas

We are also waiting for an update on this. Otherwise, we'll have to move on to another platform.

Alec-Bailey avatar Mar 02 '23 19:03 Alec-Bailey

Is there any official to-do list or features backlog for the Jetpack Compose support?

aabolfazl avatar Jun 30 '23 07:06 aabolfazl

It is not the official support, but @RomanBapst and I have been working on a small Jetpack Compose layer for Mapbox (and MapLibre) called ramani-maps. It is still fairly new, and we still have to solve some issues with Mapbox (e.g. this one, but for some use-cases that is not a problem).

For now we have only added features that we use ourselves, and we hope that it may be useful for others. We want to keep adding features steadily, and obviously we are open to contributions.

Some people here mentioned having to move to another platform if Compose doesn't come to Mapbox (we know there is work in progress), so we hope that maybe this helps bridging the gap.

The project is available on GitHub: https://github.com/ramani-maps/ramani-maps

JonasVautherin avatar Jul 16 '23 21:07 JonasVautherin

Thanks for your patience. We're thrilled to unveil our first official Jetpack Compose Extension, now available for public preview. Your feedback is invaluable to us. Please share your thoughts so we can enhance the experience for everyone. Thank you!

pengdev avatar Aug 11 '23 22:08 pengdev

Closing this issue for now, please feel free to open any Jetpack Compose related issues here with label compose.

kiryldz avatar Aug 14 '23 09:08 kiryldz