Skip to content

Commit

Permalink
feat: Rename example codes that were using the position parameter t…
Browse files Browse the repository at this point in the history
…o `initialPosition`. googlemaps#637
  • Loading branch information
JSpiner authored and smith.jspiner committed Oct 16, 2024
1 parent 17fa80c commit 34a1a7d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AccessibilityActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
val singaporeState = rememberMarkerState(position = singapore)
val singaporeState = rememberMarkerState(initialPosition = singapore)
val cameraPositionState = rememberCameraPositionState {
position = defaultCameraPosition
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ fun GoogleMapView(
mapColorScheme: ComposeMapColorScheme = ComposeMapColorScheme.FOLLOW_SYSTEM,
content: @Composable () -> Unit = {}
) {
val singaporeState = rememberMarkerState(position = singapore)
val singapore2State = rememberMarkerState(position = singapore2)
val singapore3State = rememberMarkerState(position = singapore3)
val singapore4State = rememberMarkerState(position = singapore4)
val singaporeState = rememberMarkerState(initialPosition = singapore)
val singapore2State = rememberMarkerState(initialPosition = singapore2)
val singapore3State = rememberMarkerState(initialPosition = singapore3)
val singapore4State = rememberMarkerState(initialPosition = singapore4)

var circleCenter by remember { mutableStateOf(singapore) }
if (!singaporeState.isDragging) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private fun GoogleMapViewInColumn(
cameraPositionState: CameraPositionState,
onMapLoaded: () -> Unit,
) {
val singaporeState = rememberMarkerState(position = singapore)
val singaporeState = rememberMarkerState(initialPosition = singapore)

var uiSettings by remember { mutableStateOf(MapUiSettings(compassEnabled = false)) }
var mapProperties by remember {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class RecompositionActivity : ComponentActivity() {
cameraPositionState: CameraPositionState = rememberCameraPositionState(),
content: @Composable () -> Unit = {},
) {
val markerState = rememberMarkerState(position = singapore)
val markerState = rememberMarkerState(initialPosition = singapore)

val uiSettings by remember { mutableStateOf(MapUiSettings(compassEnabled = false)) }
val mapProperties by remember {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class AdvancedMarkersActivity : ComponentActivity(), OnMapsSdkInitializedCallbac
val mapProperties by remember {
mutableStateOf(MapProperties(mapType = MapType.NORMAL))
}
val marker1State = rememberMarkerState(position = santiago)
val marker2State = rememberMarkerState(position = bogota)
val marker3State = rememberMarkerState(position = lima)
val marker4State = rememberMarkerState(position = salvador)
val marker1State = rememberMarkerState(initialPosition = santiago)
val marker2State = rememberMarkerState(initialPosition = bogota)
val marker3State = rememberMarkerState(initialPosition = lima)
val marker4State = rememberMarkerState(initialPosition = salvador)

// Drawing on the map is accomplished with a child-based API
val markerClick: (Marker) -> Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fun GoogleMapClustering(items: List<MyItem>) {
}

MarkerInfoWindow(
state = rememberMarkerState(position = singapore),
state = rememberMarkerState(initialPosition = singapore),
onClick = {
Log.d(TAG, "Non-cluster marker clicked! $it")
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private fun DraggableMarker(
onDrag: (LatLng) -> Unit = {},
onDragEnd: () -> Unit = {}
) {
val markerState = rememberMarkerState(position = singapore)
val markerState = rememberMarkerState(initialPosition = singapore)

Marker(
state = markerState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ fun rememberUpdatedMarkerState(position: LatLng): MarkerState =
// rememberUpdatedState() uses MutableState, we use MarkerState.
// This is more efficient than updating position in an effect,
// as we avoid an additional recomposition.
remember { MarkerState(position = position) }.also {
remember { MarkerState(initialPosition = position) }.also {
it.position = position
}

0 comments on commit 34a1a7d

Please sign in to comment.