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

Eduardo Ruesta

03/07/2024, 4:25 PM
Hey guys! im working in a Compose Multiplatform app... need to show a Map like Google Map with a marker ( i know lat and long) Do you know which library can i use? another question: if i use Google Maps in the Android side... for example i created
expect showMap
and set to true only in android! how can i check that condition and show or not some composable function that i only create it in the Android side not in the common
j

Joel Denke

03/07/2024, 4:43 PM
I havent used Google Maps in CMP app myself, but if they do not have any Android specifics required I think can add dependecy into commonMain, by point to the android jvm variant directly but not sure. Otherwise would try to add the library into both iosMain + androidMain lets say each block and call the compose code from both in expect/actual refer to same code in Google Maps.
The complexity here is using libraries that is NOT KMP aware of different targets, so need to provide that information yourself in Gradle scope.
e

Eduardo Ruesta

03/07/2024, 4:55 PM
Thank Joel! i'll do it... can i call a composable function and add it the expect/actual?
j

Joel Denke

03/07/2024, 4:58 PM
Not entirely sure, depends how the compose library is shipped. Need to expose it kind a through Kotlin. I have never done this myself, so I dont know really.
In theory it looks like https://github.com/googlemaps/android-maps-compose/blob/main/maps-compose/build.gradle is using libraries thats compatible in KMP world, but its another thing how to resolve with Compose multiplatform androidx compose bridge. Like let Google maps using compose multiplatform so to say backwards into commonMain 😛
Here is sample project using Google maps: https://github.com/realityexpander/FredsRoadtripStoryteller/blob/main/shared/src/commonMain/kotlin/GoogleMaps.kt However they using cocoapods for iOS for Google Maps and provide the commonMain bridge in that way. So using in iOS native cocoapods with expect/actual and for Android they using Google Maps compose library.
e

Eduardo Ruesta

03/07/2024, 5:09 PM
ohh!! thank you very much Joel! i’ll take a look on every thing you said…
j

Joel Denke

03/07/2024, 5:12 PM
Best of luck, hope it works well 🙂 Maybe someone else done this road before and will be able answer as well. Would be interesting hear if working good, as I maybe want to use it as well in the future. Always nice to hear which libraries you can use vs not 🙂
e

Eduardo Ruesta

03/07/2024, 5:21 PM
Of course!! i’ll let you know how it was. and the problems I had to face (surely) haha
b

brandonmcansh

03/09/2024, 1:54 PM
Went the cocoapod route for my airbnb sample with great success. 😀
e

Eduardo Ruesta

03/09/2024, 3:00 PM
Hey @brandonmcansh!!! Do you have the repo URL to take a look on what you’ve been doing? Thanks
Or do you have the steps you did to add map on yor app? It will help me a lot thanks
6 Views