Created
June 5, 2021 14:53
-
-
Save hkawii/d1f92814cdcb113697c6ffc5155e5e92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun MapViewContainer( | |
isEnabled: Boolean, | |
mapView: MapView, | |
viewModel: MapViewModel | |
) { | |
AndroidView( | |
factory = { mapView } | |
) { | |
mapView.getMapAsync { map -> | |
map.uiSettings.setAllGesturesEnabled(isEnabled) | |
val location = viewModel.location.value | |
val position = LatLng(location.latitude, location.longitude) | |
map.moveCamera(CameraUpdateFactory.newLatLngZoom(position, 15f)) | |
map.setOnCameraIdleListener { | |
val cameraPosition = map.cameraPosition | |
viewModel.updateLocation(cameraPosition.target.latitude, cameraPosition.target.longitude) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment