@Composable
fun KakaoMap(
modifier: Modifier = Modifier,
locationX: Double,
locationY: Double,
) {
val context = LocalContext.current
val mapView = remember { MapView(context) }
AndroidView(
modifier = modifier
.height(200.dp),
factory = { context ->
mapView.apply {
mapView.start(
object : MapLifeCycleCallback() {
override fun onMapDestroy() {
makeToast(context = context, message = "지도를 불러오는데 실패했습니다.")
}
override fun onMapError(exception: Exception?) {
makeToast(context = context, message = "지도를 불러오는 중 알 수 없는 에러가 발생했습니다. $exception")
Log.e("KakaoMap", "onMapError: $exception")
}
},
object : KakaoMapReadyCallback() {
override fun onMapReady(kakaoMap: KakaoMap) {
Log.e("x, y value", "$locationX $locationY")
val cameraUpdate = CameraUpdateFactory.newCenterPosition(LatLng.from(locationX, locationY))
val style = kakaoMap.labelManager?.addLabelStyles(LabelStyles.from(LabelStyle.from(com.msg.design_system.R.drawable.ic_new_bitgoeul)))
val options = LabelOptions.from(LatLng.from(locationX, locationY)).setStyles(style)
val layer = kakaoMap.labelManager?.layer
kakaoMap.moveCamera(cameraUpdate)
layer?.addLabel(options)
}
override fun getPosition(): LatLng {
return LatLng.from(locationX, locationY)
}
},
)
}
},
)
}
안녕하세요 고등학교에 재학중인 학생입니다.
카카오맵을 구현도중 질문사항이 생겨 질문드립니다.
현재 위의 코드를
Jetpack Compose 1.5.4 버전
Android 13 버전
API Level 33
을 사용하여 KakaoMap UI를 구현중에 있습니다.
서버측에서 locationX, Y 값을 반환해주고 그 값을 KakaoMap으로 넘기는 과정을 거치고 있습니다.
하지만 이와 같은 과정에서 에뮬레이터를 실행시켜 UI를 확인하면 노르스름한 UI만 확인이 가능합니다.
혹시 이에 대한 해결책이 있을까요?
지도를 열었을 때, “k3f” 문자로 필터링 된 로그캣 로그 첨부 부탁 드립니다.
2024-08-08 14:56:16.084 12845-13124 K3fAApi com.msg.bitgoeul_android D ---> RequestHeader(https://dapi.kakao.com/v2/maps/vector/auth) {Accept=[application/json], Authorization=[KakaoAK 237453a51220adf0b261dfee45fa1508], KA=[sdk/13 mapSdk/2.9.5 os/android-33 lang/en-US device/sdk_gphone64_arm64 origin/IPuN8vUu0iP4BQhnLDQgumd/weg= android_pkg/com.msg.bitgoeul_android]}
2024-08-08 14:56:16.099 12845-13123 K3fAApi com.msg.bitgoeul_android D AppSpec : High spec
2024-08-08 14:56:16.099 12845-13123 K3fCore com.msg.bitgoeul_android I app diplay scale: 1.500000
2024-08-08 14:56:16.099 12845-13123 K3fAApi com.msg.bitgoeul_android V + e s(2.9.5, f95e4aae, c908ed058 1.500000, com.msg.bitgoeul_android)
2024-08-08 14:56:16.123 12845-13123 K3fCore com.msg.bitgoeul_android I DownloadManager initialized
2024-08-08 14:56:16.141 12845-13123 K3fCore com.msg.bitgoeul_android I >>> Initialize appEngine[RELEASE]{1723096576}
2024-08-08 14:56:16.145 12845-13123 K3fCore com.msg.bitgoeul_android I >>> Start appEngine[RELEASE]{1723096576}
2024-08-08 14:56:16.146 12845-13123 K3fCore com.msg.bitgoeul_android I android high
2024-08-08 14:56:16.150 12845-13123 K3fCore com.msg.bitgoeul_android I DownloadManager initialized
2024-08-08 14:56:16.154 12845-13123 K3fCore com.msg.bitgoeul_android I start to make a map view
2024-08-08 14:56:16.157 12845-13123 K3fAApi com.msg.bitgoeul_android V + e c (936, 600, openmap)
2024-08-08 14:56:16.157 12845-13123 K3fCore com.msg.bitgoeul_android I Engine{1723096576} resumed.
2024-08-08 14:56:16.157 12845-13123 K3fAApi com.msg.bitgoeul_android V - allViewport(936, 600)
2024-08-08 14:56:16.200 12845-13123 K3fCore com.msg.bitgoeul_android I onRenderViewSuccess
2024-08-08 14:56:16.212 12845-13123 K3fCore com.msg.bitgoeul_android E unsupported image format.
2024-08-08 14:56:16.213 12845-12845 K3fCore com.msg.bitgoeul_android E unsupported image format.
2024-08-08 14:56:16.213 12845-12845 K3fCore com.msg.bitgoeul_android E (2131099688) unsupported image format.
2024-08-08 14:56:16.213 12845-12845 K3fAApi com.msg.bitgoeul_android D Added Image. AssetId : [2131099688]
2024-08-08 14:56:16.228 12845-13123 K3fAApi com.msg.bitgoeul_android D [Label] addLayer(id=label_default_layer, zOrder=10001, type=0, unit=0, order=0, isLod=0) --->
2024-08-08 14:56:16.228 12845-13123 K3fAApi com.msg.bitgoeul_android D [Label] addLayer(id=lodLabel_default_layer, zOrder=10001, type=0, unit=0, order=0, isLod=1) --->
2024-08-08 14:56:16.228 12845-13123 K3fAApi com.msg.bitgoeul_android D [Label] addPointLabelStyles(id=-452396783) --->
2024-08-08 14:56:16.228 12845-13123 K3fAApi com.msg.bitgoeul_android D --> newCenterPoint(lat: 126.800772, lng: 35.142769, zoomLevel: -1, height: 1676.837324, animate: 0, duration: 0, makeViaPoint: 0, chain: 0)
2024-08-08 14:56:16.228 12845-13123 K3fAApi com.msg.bitgoeul_android D [Label] addLabel(layer=label_default_layer, styleId=-452396783, labelId=79f63b12-1f4d-4f0f-b4d5-b8a6d4bb4667, lsLod=0) --->
2024-08-08 14:56:16.424 12845-13124 K3fAApi com.msg.bitgoeul_android V <-- {null=[HTTP/1.1 200 OK], Connection=[keep-alive], Content-Length=[0], Date=[Thu, 08 Aug 2024 05:56:21 GMT], strict-transport-security=[max-age=31536000; includeSubDomains], X-Android-Received-Millis=[1723096576423], X-Android-Response-Source=[NETWORK 200], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1723096576360], X-Request-Id=[29da9de18e3c4d3b8906d6525b5deef7]}
죄송합니다. 로그캣 첨부를 잊어버렸네요. 로그캣 로그를 k3f로 필터링 하면 이러한 로그가 나옵니다.
로그를 보니, 좌표값의 Latitude 와 Longitude 의 순서가 바뀐 것 같습니다.
LatLng.from() 으로 좌표 값을 만드실 때, Latitude 와 Longitude 순서에 신경써서 넣어서 확인 부탁 드립니다.