Skip to content

Commit

Permalink
feat: added Factory for Map (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
kikoso committed Aug 7, 2023
1 parent 2422f06 commit 1974583
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,34 @@ private fun MapView.componentCallbacks(): ComponentCallbacks =
this@componentCallbacks.onLowMemory()
}
}

public typealias GoogleMapFactory = @Composable () -> Unit

@Composable
public fun googleMapFactory(
modifier: Modifier = Modifier,
cameraPositionState: CameraPositionState = rememberCameraPositionState(),
onMapLoaded: () -> Unit = {},
content: @Composable () -> Unit = {}
): GoogleMapFactory {
return {
val uiSettings by remember { mutableStateOf(MapUiSettings(compassEnabled = false)) }
val mapProperties by remember {
mutableStateOf(MapProperties(mapType = MapType.NORMAL))
}

val mapVisible by remember { mutableStateOf(true) }

if (mapVisible) {
GoogleMap(
modifier = modifier,
cameraPositionState = cameraPositionState,
properties = mapProperties,
uiSettings = uiSettings,
onMapLoaded = onMapLoaded,
content = content
)
}
}
}

0 comments on commit 1974583

Please sign in to comment.