Android
[kakaomap] 현재 위치 마커 커스텀 이미지로 변경하기
hanbikan
2021. 7. 9. 23:28
정말 간단하다.
setCustomCurrentLocationMarkerTrackingImage(int id, MapPOIItem.ImageOffset anchorPointOffset)
메소드 하나만 사용하면 된다. 예시는 아래와 같다.
mapView.setCustomCurrentLocationMarkerTrackingImage(R.drawable.marker_current_location, MapPOIItem.ImageOffset(16, 16))
다만, 여기서 알아야할 것이 두 가지 있다.
- id에 해당하는 drawable id는, 비트맵 이미지의 id여야한다. 즉, png 같은 파일을 drawable에 넣고, 이것을 참조하여야 한다는 의미이다.
- anchorPointOffset은 중점을 설정하는 부분이다. ImageOffset(0, 0)으로 두면 오른쪽 위 방향으로 이미지가 치우쳐져있는 걸 알 수 있다. 즉, bottom-left를 기준으로 중점 픽셀을 입력하는 것이다. 위의 예시에서 16, 16으로 둔 것은, 해당 이미지가 32x32 크기이기 때문이다.