Generalidades

Jetpack Compose: Google Maps Camera Motion Listener | Erselan Khan | Por Erselan Khan | Marzo de 2022

Jetpack Compose Google Maps Camera Motion Listener Erselan Khan
dependencies {
implementation "com.google.maps.android:maps-compose:1.0.0"
implementation "com.google.android.gms:play-services-maps:18.0.2"

}
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Compose">
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Compose">



android:name="com.google.android.geo.API_KEY"
android:value="AIza*************************"/>

val markerPosition = LatLng(1.35, 103.87)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(markerPosition, 15f)
}
GoogleMap
(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState
) {
Marker(
position = markerPosition,
title = "Your Title",
snippet = "Place Name"
)
}
1648286972 270 Jetpack Compose Google Maps Camera Motion Listener Erselan Khan
@Composable
fun MapScreen() {
val markerPosition = LatLng(1.35, 103.87)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(markerPosition, 18f)
}
GoogleMap
(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState
)

Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
IconButton
(
onClick = {

},
) {
Image
(
painter = painterResource(id = R.drawable.ic_map_marker),
contentDescription = "marker",
)
}
}
}

Text(text = "Is camera moving: ${cameraPositionState.isMoving}" +
"\n Latitude and Longitude: ${cameraPositionState.position.target.latitude} " +
"and ${cameraPositionState.position.target.longitude}",
textAlign = TextAlign.Center
)
@Composable
fun MapScreen() {
val markerPosition = LatLng(1.35, 103.87)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(markerPosition, 18f)
}
GoogleMap
(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState
)

Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
IconButton
(
onClick = {

},
) {
Image
(
painter = painterResource(id = R.drawable.ic_map_marker),
contentDescription = "marker",
)
}

Text(text = "Is camera moving: ${cameraPositionState.isMoving}" +
"\n Latitude and Longitude: ${cameraPositionState.position.target.latitude} " +
"and ${cameraPositionState.position.target.longitude}",
textAlign = TextAlign.Center
)
}
}

LEER  Cómo capturar capturas de pantalla en la aplicación en Android | Autor Siva Ganesh Kantamani | Agosto de 2021

Publicaciones relacionadas

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Botón volver arriba