원하는 좌표에 마커 만들기
val mapPOIItem = mutableListOf<MapPOIItem>()
mapPOIItem.add(getMapPOIItem("ㅌㅅㅌ", 35.86401751026963, 128.6485239265323))
mapPOIItem.add(getMapPOIItem("ㅌㅅㅌ", 35.85881638638933, 128.6356195137821))
mapView.addPOIItems(mapPOIItem.toTypedArray())
맵뷰 세팅
MapView.setMapTilePersistentCacheEnabled(true)
mapView = MapView(activity)
binding.mapViewContainer.addView(mapView)
mapView.setZoomLevel(2, true)
mapView.setMapViewEventListener(this)
mapView.setCurrentLocationEventListener(this)
mapView.setCustomCurrentLocationMarkerImage(R.drawable.ic_my_location, MapPOIItem.ImageOffset(108, 0))
mapView.setCustomCurrentLocationMarkerTrackingImage(R.drawable.ic_my_location, MapPOIItem.ImageOffset(108, 0))
현재위치에서 주소 받아오는 함수
private fun getJusoFromGeoCord(mapPoint: MapPoint?) {
mapPoint?.let {
val currentMapPoint = MapPoint.mapPointWithGeoCoord(mapPoint.mapPointGeoCoord.latitude, mapPoint.mapPointGeoCoord.longitude)
MapReverseGeoCoder(BuildConfig.appKey, currentMapPoint, object : MapReverseGeoCoder.ReverseGeoCodingResultListener {
override fun onReverseGeoCoderFoundAddress(p0: MapReverseGeoCoder?, address: String) {
}
override fun onReverseGeoCoderFailedToFindAddress(p0: MapReverseGeoCoder?) {
toast("주소를 찾을 수 없습니다.")
}
}, activity).startFindingAddress()
}
}
카카오지도 api