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

Guy Bieber

06/04/2020, 3:15 AM
Has anyone integrated google maps into a compose app? I am looking for example code if it exists.
j

John O'Reilly

07/05/2020, 1:38 PM
Did you find any examples of this? I have app that uses
SupportMapFragment
right now and looking to get working with Compose....curious how data source that for example drives placement of markers would be managed.....and likewise where panning of map triggers data query/update
@romainguy I just saw that you mentioned using
AndroidView
....do you know of any examples of this used for a map like this?
I have basic setup working using
AndroidView
with a layout file that includes
com.google.android.gms.maps.SupportMapFragment
fragment ....looking next at what options are for accessing map and tying in for example with map lifecycle callbacks
ok, looks like I can do something like
Copy code
AndroidView(resId = R.layout.fragment_nearby, modifier = Modifier.weight(0.4f)) {
    val mapFragment = fragmentManager.findFragmentById(R.id.map) as SupportMapFragment

    mapFragment.getMapAsync {map ->
        map.isMyLocationEnabled = true
    }
}
👍 1