I will point the camera to the coordinates according to the existing API. but only the marker can go to the coordinates but not the camera.
Please help
I include my code snippet
// Membuat objek LatLng dari nilai latitude dan longitude
val coordinatesStr = gempaInfo?.infogempa?.gempa?.coordinates
val (latitudeStr, longitudeStr) = coordinatesStr?.split(",") ?: listOf("0.0", "0.0")
val latitude = latitudeStr.trim().toDoubleOrNull() ?: 0.0
val longitude = longitudeStr.trim().toDoubleOrNull() ?: 0.0
val koordinat = LatLng(latitude, longitude)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(koordinat, 10f)
}
// Menampilkan peta Google dengan marker di koordinat
GoogleMap(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState
) {
Marker(
state = MarkerState(position = koordinat),
title = "Lokasi Gempa",
snippet = "Marker di lokasi gempa"
)
}
I want when the map is loaded it will automatically point to the coordinates according to what has been created by the API