Created
May 16, 2022 16:47
-
-
Save arriolac/605e91242dd0b8068f968e37b3e375a6 to your computer and use it in GitHub Desktop.
Maps Compose Snippets
This file contains hidden or 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
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
val singapore = LatLng(1.35, 103.87) | |
val cameraPositionState = rememberCameraPositionState { | |
position = CameraPosition.fromLatLngZoom(singapore, 11f) | |
} | |
Box(Modifier.fillMaxSize()) { | |
GoogleMap( | |
modifier = Modifier.matchParentSize(), | |
cameraPositionState = cameraPositionState | |
) | |
val coroutineScope = rememberCoroutineScope() | |
Button(onClick = { | |
coroutineScope.launch { | |
cameraPositionState.animate( | |
CameraUpdateFactory.zoomIn() | |
) | |
} | |
}) { | |
Text(text = "Zoom in") | |
} | |
} |
This file contains hidden or 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
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
GoogleMap(modifier = Modifier.fillMaxSize()) { | |
Marker( | |
state = MarkerState(LatLng(1.35, 103.87)), | |
title = "Marker in Singapore", | |
onClick = { Log.d("Marker", "Marker was clicked") } | |
) | |
} |
This file contains hidden or 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
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
GoogleMap( | |
properties = MapProperties(isBuildingEnabled = true) | |
// … | |
) |
This file contains hidden or 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
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
MyAppTheme { | |
GoogleMap( | |
//… | |
) { | |
Circle( | |
center = singapore, | |
fillColor = MaterialTheme.colors.primary | |
) | |
} | |
} |
This file contains hidden or 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
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
GoogleMap( | |
uiSettings = MapUiSettings(compassEnabled = false, mapToolbarEnabled = true) | |
// … | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment