Tracking center coords - Picplz/picplz-aos GitHub Wiki
kakaoMap.setOnCameraMoveEndListener
ํด๋น ๋ฆฌ์ค๋๋ฅผ ํธ์ถํด์ onCameraMoveEnd
๋ฅผ ํตํด ์นด๋ฉ๋ผ๊ฐ ์์ง์์ด ์ข
๋ฃ๋์์ ๋ ๋์์ด ์๋ํ๋๋ก ์ค์ ๊ฐ๋ฅํ๋ค
public interface OnCameraMoveEndListener {
void onCameraMoveEnd(@NonNull KakaoMap var1, @NonNull CameraPosition var2, @NonNull GestureType var3);
}
์ด ํจ์๋ 3๊ฐ์ง์ ๋งค๊ฐ๋ณ์๋ฅผ ์
๋ ฅ๋ฐ์ผ๋ฉฐ ์ฌ๊ธฐ์ CameraPosition
์
CameraPosition(double latitude, double longitude, int zoomLevel, double tiltAngle, double rotationAngle, double height) {
this.position = LatLng.from(latitude, longitude);
this.zoomLevel = zoomLevel;
this.tiltAngle = tiltAngle;
this.rotationAngle = rotationAngle;
this.height = height;
}
์์ ๊ฐ์ ์์ฑ์ ๊ฐ์ง๊ณ ์๋ค
@Composable
fun KakaoMapView(
...
onCameraMoveEnd: (KakaoMap, CameraPosition, GestureType) -> Unit = { _: KakaoMap, _: CameraPosition, _: GestureType -> },
) {
var mapView by remember { mutableStateOf<MapView?>(null) }
AndroidView(
modifier = modifier,
factory = { context ->
MapView(context).also { mapView = it }.apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
start(
object : MapLifeCycleCallback() {
...
},
object : KakaoMapReadyCallback() {
override fun onMapReady(kakaoMap: KakaoMap) {
// ์ธ์ฆ ํ API๊ฐ ์ ์์ ์ผ๋ก ์คํ๋ ๋ ํธ์ถ๋จ
onMapReady(kakaoMap)
kakaoMap.setOnCameraMoveEndListener { cameraListenerKakaoMap, cameraPosition, gestureType ->
onCameraMoveEnd(
cameraListenerKakaoMap,
cameraPosition,
gestureType
)
}
}
...
}
)
}
}
)
val lifecycleOwner = LocalLifecycleOwner.current
DisposableEffect(lifecycleOwner) {
val observer = object : DefaultLifecycleObserver {
...
}
lifecycleOwner.lifecycle.addObserver(observer)
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
}
}
}
์นด์นด์ค๋งต๋ทฐ๋ฅผ ์์ ๊ฐ์ด ์์ฑํด์ setOnCameraMoveEndListener๋ฅผ ์ค์ ํ ํ
KakaoMapView(
...
onCameraMoveEnd = {_, cameraPosition, _ ->
viewModel.handleIntent(SearchPhotographerIntent.SetCenterCoords(cameraPosition.position))
}
)
์ด์ฒ๋ผ ๋งค๊ฐ๋ณ์๋ก onCameraMoveEnd ๋์์ ์ถ๊ฐํด์ค๋ค