Android
[ 안드로이드 - 코틀린 ] KakaoMap API marker 이벤트 처리하기
js1024
2023. 2. 9. 18:06
오늘의 할일 - 카카오 API 이용하며 지도에 있는 마커 이벤트 처리하기
어댑터에서 만든 이밴트와 함수이다
// 클릭시 해당 값을 위치로 지도 이동 후 마커 출력
holder.stateMove.setOnClickListener {
mapView.setZoomLevel(0, false)
mapView.setCalloutBalloonAdapter(CustomBalloonAdapter(mainActivity.layoutInflater, position, roomList))
makerEvent(roomList[position].roomName, roomList[position].latitude, roomList[position].longitude, position)
}
fun makerEvent(itemName: String, latitude: Double, longitude: Double, position: Int) {
mapView.removeAllPOIItems()
Log.d("makerEvent", "${position}")
marker.itemName = itemName
marker.mapPoint = MapPoint.mapPointWithGeoCoord(latitude, longitude)
mapView.setMapCenterPoint(MapPoint.mapPointWithGeoCoord(latitude, longitude), true)
marker.markerType = MapPOIItem.MarkerType.CustomImage
marker.customImageResourceId = R.drawable.vec2
marker.isShowCalloutBalloonOnTouch = false
marker.isCustomImageAutoscale = true
marker.setCustomImageAnchor(0.5f, 1.0f)
mapView.addPOIItem(marker)
Log.d("makerEvent", "marker_event")
}