I have implemented Google Map View in Jetpack comp...
# compose
j
I have implemented Google Map View in Jetpack compose using AndroidView (viewInterop in compose)
Copy code
1.    AndroidView(
2.        factory = { mapView },
3.        update = { mapView ->
4.            mapView.getMapAsync { map ->
5.                Log.e("insidemap", "${map.hashCode()}")
Problem is i'm getting new instance of map inside
getMapAsync
everytime there is a change in the state. any idea why so, due to this drawn overlays, polyline and polygons are being redrawn and jerking frequently
Copy code
Due to some personal reasons I'm not able to use Jetpack compose maps so please give any idea for the above impl
j
For future reference, this question is probably better asked in #compose-android since it deals with android-specific APIs. That said, I'll try to answer here. It's hard to tell without being able to look at the rest of your code, but my best guess is that your mapView is being re-created outside of the lifecycle of the call to
AndroidView
because it is not being created within the
factory
lambda. Your
factory
lambda is ideally supposed to create your mapView, not just return a reference to the map view. I realize that some of the
AndroidView
examples do a poor job of showing this, or sometimes even do the wrong thing.